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
- 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
- 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.