aboutsummaryrefslogtreecommitdiffstats
path: root/csci1913/Java
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-12-10 10:28:36 -0600
committerRossTheRoss <msattr@gmail.com>2019-12-10 10:28:36 -0600
commitbe2a1385a680c2a12488de5def4eeeac700d2f5d (patch)
tree12613f354cbd8c8390ac4db71ef77156f0385501 /csci1913/Java
parentMore (diff)
downloadhomework-be2a1385a680c2a12488de5def4eeeac700d2f5d.tar
homework-be2a1385a680c2a12488de5def4eeeac700d2f5d.tar.gz
homework-be2a1385a680c2a12488de5def4eeeac700d2f5d.tar.bz2
homework-be2a1385a680c2a12488de5def4eeeac700d2f5d.tar.lz
homework-be2a1385a680c2a12488de5def4eeeac700d2f5d.tar.xz
homework-be2a1385a680c2a12488de5def4eeeac700d2f5d.tar.zst
homework-be2a1385a680c2a12488de5def4eeeac700d2f5d.zip
More little formatting
Diffstat (limited to 'csci1913/Java')
-rw-r--r--csci1913/Java/project3/project3_strap012.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/csci1913/Java/project3/project3_strap012.java b/csci1913/Java/project3/project3_strap012.java
index c2f372a..aeec1b8 100644
--- a/csci1913/Java/project3/project3_strap012.java
+++ b/csci1913/Java/project3/project3_strap012.java
@@ -33,11 +33,11 @@ class AnagramTree {
boolean goLeft = false, addWord = false;
while (bottom != null) {
int comp = compareSummaries(bottom.summary, newSumm);
- if (comp > 0) { // left is less than right, go left
+ if (comp > 0) { // left is greater than right, go left
top = bottom;
goLeft = true;
bottom = bottom.left;
- } else if (comp < 0) { // right is less, go right
+ } else if (comp < 0) { // right is greater, go right
top = bottom;
goLeft = false;
bottom = bottom.right;
@@ -45,6 +45,7 @@ class AnagramTree {
WordNode badNode = bottom.words;
boolean wordExists = false;
while (badNode != null) {
+ //Traverse word list to find already added entries
if (badNode.word.equals(word))
wordExists = true;
badNode = badNode.next;
@@ -55,7 +56,7 @@ class AnagramTree {
break;
}
}
- if (!addWord) { //Word was not added, keep going
+ if (!addWord) { //Word was not added (or already exists), keep going
if (goLeft)
top.left = new TreeNode(word, newSumm);
else
@@ -98,6 +99,7 @@ class AnagramTree {
return left[i] - right[i];
}
}
+ //Summaries are identical
return 0;
}