title: Algorithm to find for all points in set A the nearest neighbor in set B
body: <p>Suppose we have two sets of points A, B, and we want to find for every point in set A its nearest neighbor in set B. </p>
  
  <p>There are many good algorithms to find the nearest neighbor for one point. Is there some way to use the information we got for a_1, to more efficiently search for the nearest neighbor for a_2 or other points in the set?</p>
  
  <p>I am thinking something like: use triangular inequlity to get a interval for possible distance between every point in B and new point a_2, and sort the max and min of the intervals, and then I can search only the points in B which falls in the first interval.</p>