aboutsummaryrefslogtreecommitdiffstats
path: root/csci1913
diff options
context:
space:
mode:
Diffstat (limited to 'csci1913')
-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;
}