Skip to content

Commit 303acb7

Browse files
author
Justin Wetherell
committed
Found a small bug in KdTree
1 parent aca62f3 commit 303acb7

File tree

1 file changed

+2
-2
lines changed
  • src/com/jwetherell/algorithms/data_structures

1 file changed

+2
-2
lines changed

src/com/jwetherell/algorithms/data_structures/KdTree.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ else if (axis == Y_AXIS)
149149
}
150150
}
151151

152-
if ((medianIndex - 1) >= 0 && less.size() > 0) {
152+
if ((medianIndex-1 >= 0) && less.size() > 0) {
153153
node.lesser = createNode(less, k, depth + 1);
154154
node.lesser.parent = node;
155155
}
156156

157-
if ((medianIndex + 1) <= (list.size() - 1) && more.size() > 0) {
157+
if ((medianIndex <= list.size()-1) && more.size() > 0) {
158158
node.greater = createNode(more, k, depth + 1);
159159
node.greater.parent = node;
160160
}

0 commit comments

Comments
 (0)