Skip to main content

Posts

Showing posts with the label kdtree

Nearest Neighbor Search Using KdTree

//Input should be in input.txt file //10(2.1,4.3)(3.3,1.5)(4.7,11.1)(4.9,1.6)(5.0,12.3)(5.1,1.2)(6.7,3.3)(19.2,5.4)(20.5,7.9)(100.3,52) //The first number is the number of points, n, and following it are the coordinates of the n points in ascending order of the x-coordinate. import java.util.*; import java.lang.*; import java.io.*; import java.util.StringTokenizer; class KDNode {     int axis;     double[] x;     int id;     boolean checked;     boolean orientation;     KDNode Parent;     KDNode Left;     KDNode Right;     public KDNode(double[] x0, int axis0) {         x = new double[2];         axis = axis0;         for (int k = 0; k < 2; k++)             x[k] = x0[k];         Left = Right = Parent = null;         checked = false; ...