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