fixed error
This commit is contained in:
parent
15e26130cf
commit
2be7b31b17
@ -74,20 +74,19 @@ public class TreeTraversal<T extends Comparable<T>> implements Traversal<T> {
|
||||
if (node != null) {
|
||||
|
||||
// only visit nodes that are in the interval
|
||||
if (min.compareTo(node) <= 0 && max.compareTo(node) >= 0)
|
||||
v.visit(root.element);
|
||||
if (min.compareTo(node.element) <= 0 && max.compareTo(node.element) >= 0) {
|
||||
v.visit(node.element);
|
||||
}
|
||||
|
||||
// go in the direction of lower values (so left) until the min is hit
|
||||
if (min.compareTo(node) <= 0) {
|
||||
if (min.compareTo(node.element) <= 0) {
|
||||
interval(node.left, min, max, v);
|
||||
}
|
||||
|
||||
// go in the direction of higher values (so right) until the max is hit
|
||||
if (max.compareTo(node) >= 0) {
|
||||
if (max.compareTo(node.element) >= 0) {
|
||||
interval(node.right, min, max, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user