0

I would like some clarification on this algorithm to find the closest pair of points in a set of points.

So one way to solve this is to recursively divide the points in half, finding the closest pair of points in each half. Then we have to check the strip in the middle of the points to see if there are any pairs in there that are closer.

My steps for solving this were: 1. take all fo the points and sort by the X-coordinate, then dividing the points in half. 2. recursively find the closets pair in each half

  1. find the points that are in the center strip(calculated by taking the midpoint x-coordinate +/- the minimum distance found so far) and separate them out

HERE IS MY QUESTION

  1. I sort the points that fall within this strip by their y-coordinate and then go through them to check if there are a set of points that are closer together.

The part where I am confused - should I be comparing these points just to other points in the strip to see if there is a closer pair, or should I be checking the points against their neighbors in the original set of points from step 1 that are sorted by the x-coordinate.

I know that there is a proof that I would only need to check a certain number of the neighbors, but I am confused as to whether or not the 'neighbors' are from the original set of points or if I should only be looking at the points in the center strip.

I hope this makes sense - thanks for any clarification.

Edit: I wanted to say that I think I would just compare the points within the strip itself(since anything outside of the strip would have been compared when we looked at the halves) - I just wanted to clarify. Also yes, this is the canonical D&C version of the algorithm, I am just trying to make sure I am understanding it correctly and the points within the middle strip were causing me a bit of confusion.

LVNGD
  • 169
  • 3
  • 12
  • Can you provide a drawing of your steps? It isn't clear to me what the "strips" are. – Bernd Strehl May 30 '17 at 19:46
  • @Strernd This is standard D & C solution of this problem. You can check strip here https://en.wikipedia.org/wiki/Closest_pair_of_points_problem – Shashwat Kumar May 30 '17 at 19:49
  • Sorting the points again by their y-coordinates will cause the complexity to worsen. – Shashwat Kumar May 30 '17 at 19:54
  • Please see the excellent discussion here, which starts with 1D then generalizes to 2D. Then you should be able to answer your own question, which is much better than having someone answer it for you: https://www.cs.ucsb.edu/~suri/cs235/ClosestPair.pdf – Gene May 30 '17 at 19:56

0 Answers0