Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Closest pair of points

In http://en.wikipedia.org/wiki/Closest_pair_of_points_problem we can see that it mentions that is at most 6 points that is closest to the point on the other half, which can be represented as the graph below: enter image description here

My question is for point P1 and Point P2, the distance to the red point will exceed sqrt(2)*d, why it is part of the solution? Why it is not at most 4 points that is closest to P rather than at most 6 points? Thanks.

like image 306
william007 Avatar asked Sep 15 '12 12:09

william007


People also ask

How do you find the closest pair of points?

1) We sort all points according to x coordinates. 2) Divide all points in two halves. 3) Recursively find the smallest distances in both subarrays. 4) Take the minimum of two smallest distances.

What do you mean by closest pair problem?

The closest pair of points problem or closest pair problem is a problem of computational geometry: given. points in metric space, find a pair of points with the smallest distance between them.

What is the closest pair explain the closest pair algorithm?

In this problem, a set of n points are given on the 2D plane. In this problem, we have to find the pair of points, whose distance is minimum. To solve this problem, we have to divide points into two halves, after that smallest distance between two points is calculated in a recursive way.

Is closest pair divide and conquer?

As a pre-processing step, the input array is sorted according to x coordinates. 1) Find the middle point in the sorted array, we can take P[n/2] as middle point. 2) Divide the given array in two halves. The first subarray contains points from P[0] to P[n/2].


2 Answers

P1 and P2 are not part of the solution, but they have to be examined on the way to the solution, because the algorithm examines all points in the box, and P1 and P2 are in the box.

Note that no such point as your Q can exist, because by hypothesis the minimum distance between points in the right-hand half of the diagram is d.

Edited to add: you seem to think that the Wikipedia article is making a claim like this:

  • There may be up to 6 points on the right side of the line that are within a distance d of P.

This claim would be false. But the article does not make such a claim. Instead, it makes two separate claims, both of which are true:

  1. All the points on the right side of the line that are within a distance d of P are inside the box.
  2. There may be up to 6 points in the box.

like image 178
Gareth Rees Avatar answered Oct 05 '22 04:10

Gareth Rees


We are only counting the maximum number of points that can lie in the right d x 2d rectangle. Since any two points are constrained to have a minimum distance of d, we can place at most 6 points in the rectangle while satisfying this constraint, as shown in the figure.

Note that the points on the right side that are within d distance from P should all lie within a circular segment of a circle centered at P and whose radius is d. There can be at most 4 points in this segment. However, finding the number of points within a segment is more complicated than finding the number of points within a rectangle. So we use the rectangle instead and incur an extra cost of having to search for at most 2 additional points.

like image 31
krjampani Avatar answered Oct 05 '22 06:10

krjampani