diff --git a/kdtree.h b/kdtree.h index 32bf324..6b8ab66 100644 --- a/kdtree.h +++ b/kdtree.h @@ -98,7 +98,7 @@ class KDTree { // TODO: This copies. Can we split the vector into two without copying? std::vector left_of_median(points.begin(), points.begin() + middle); - std::vector right_of_median(points.begin() + middle, points.end()); + std::vector right_of_median(points.begin() + middle + 1, points.end()); // Create node, recursively call to construct subtree return new Node(axis, median, build(left_of_median, depth + 1),