Beruflich Dokumente
Kultur Dokumente
R. Inkulu
http://www.iitg.ac.in/rinkulu/
1 / 11
Problem description
Find a closest pair of points in the given set S of n points in R2 .
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
"
111
000
000 p
111
000
111
111
000
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
000
111
111
000
000
111
000
111
000
111
000
111
for convenience, assume that no two points in S are having the same x- or y-coordi
(Finding a closest pair of points in R2 )
2 / 11
Brute-force algorithm
Computing the distance between every two points in S, and choosing a
pair with the smallest distance: O(n2 ) time.
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111 p"
000
000
111
000
111
000
p111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
3 / 11
Divide-Conquer-Combine
4 / 11
Combining solutions
(i) closest pair is from left half of points
(ii) closest pair is from right half of points
(iii) closest pair is formed by one point from left half and another from right
half how to do in O(n)?
L
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
"
111
000
000 p
111
000
111
111
000
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
(Finding a closest pair of points in R2 )
111
000
000
111
111
000
000
111
111
000
000
111
5 / 11
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
000
p"111
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
000
111
000 d
111
111
000
000
111
dR
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
111
000
000
111
d
111
000
000
111
6 / 11
00
11
00
11p
d
7 / 11
1
d/sqrt(2)
d/2
d/2
d
d/2
p
8 / 11
(a) let S be the y-sorted list of points falling within the vertical band
for each point p, find the distance between p and each of the 7 points
above p in S
(b) among all such searches, let p and p be the point pair with the minimum
distance
then return min(dist(p , p ), dL , dR ) with the corresponding points
9 / 11
Correctness
10 / 11
11 / 11