fixed error

This commit is contained in:
navid.sassan 2020-10-25 22:16:20 +01:00
parent 15e26130cf
commit 2be7b31b17

View File

@ -74,20 +74,19 @@ public class TreeTraversal<T extends Comparable<T>> implements Traversal<T> {
if (node != null) { if (node != null) {
// only visit nodes that are in the interval // only visit nodes that are in the interval
if (min.compareTo(node) <= 0 && max.compareTo(node) >= 0) if (min.compareTo(node.element) <= 0 && max.compareTo(node.element) >= 0) {
v.visit(root.element); v.visit(node.element);
} }
// go in the direction of lower values (so left) until the min is hit // 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); interval(node.left, min, max, v);
} }
// go in the direction of higher values (so right) until the max is hit // 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); interval(node.right, min, max, v);
} }
} }
} }
} }