Closest Pair of Points in the Plane
Inge Li Gørtz
Thank you to Kevin Wayne for inspiration to slides. The slides on the deterministic algorithm for finding the closest pair of points is a modification of slides made by Kevin.
Closest Pair of Points in the Plane Inge Li Grtz Thank you to Kevin - - PowerPoint PPT Presentation
Closest Pair of Points in the Plane Inge Li Grtz Thank you to Kevin Wayne for inspiration to slides. The slides on the deterministic algorithm for finding the closest pair of points is a modification of slides made by Kevin. Closest Pair of
Thank you to Kevin Wayne for inspiration to slides. The slides on the deterministic algorithm for finding the closest pair of points is a modification of slides made by Kevin.
Thank you to Kevin Wayne for inspiration to slides.
distance between them.
air traffic control.
Thank you to Kevin Wayne for inspiration to slides.
Thank you to Kevin Wayne for inspiration to slides. The slides on the deterministic algorithm for finding the closest pair of points is a modification of the slides made by Kevin.
Thank you to Kevin Wayne for inspiration to slides.
L
Thank you to Kevin Wayne for inspiration to slides.
L 12 21
Thank you to Kevin Wayne for inspiration to slides.
L 12 21 8
seems like Θ(n2)
Thank you to Kevin Wayne for inspiration to slides.
12 21 δ = min(12, 21) L
Thank you to Kevin Wayne for inspiration to slides.
12 21 δ L δ = min(12, 21)
Thank you to Kevin Wayne for inspiration to slides.
12 21 δ L δ = min(12, 21)
1 2 3 4 5 6 7
Thank you to Kevin Wayne for inspiration to slides.
12 21 δ L δ = min(12, 21)
1 2 3 4 5 6 7
Thank you to Kevin Wayne for inspiration to slides.
δ
29 30 31 28 26 25
δ
½δ ½δ
39
i j
27
δ
Thank you to Kevin Wayne for inspiration to slides.
Closest-Pair(p1, …, pn) { If n < 4 compute closest pair by comparing all pairs. Compute separation line L such that half the points are on one side and half on the other side. δ1 = Closest-Pair(left half) δ2 = Closest-Pair(right half) δ = min(δ1, δ2) Delete all points further than δ from separation line L Sort remaining points by y-coordinate. Scan points in y-order and compare distance between each point and next 7 neighbors. If any of these distances is less than δ, update δ. return δ. }
O(n log n) 2T(n / 2) O(n) O(n log n) O(n)
Thank you to Kevin Wayne for inspiration to slides.
Presort points into lists X and Y after x- and y-coordinate, respectively. Closest-Pair(X[1…n],Y[1…n]) { If n < 4 compute closest pair by comparing all pairs. Compute separation line L such that half the points are on one side and half on the other side. δ1 = Closest-Pair(left half) δ2 = Closest-Pair(right half) δ = min(δ1, δ2) Delete all points further than δ from separation line L Sort remaining points by y-coordinate. Scan points in y-order and compare distance between each point and next 7 neighbors. If any of these distances is less than δ, update δ. return δ. }
O(n) 2T(n / 2) O(n) O(n) O(n)
d(pi,pj) < δ.
3 4 11 9 10 15 5 1 2 14 12 6 13 8 7 δ2 δ1
3 4 11 9 10 15 5 1 2 14 6 13 8 7 δ δ/2 δ/2 12
3 4 11 9 10 15 5 1 2 14 6 13 8 7 δ/2 δ/2 12
3 4 11 9 10 15 5 1 2 14 6 13 8 7 δ/2 δ/2 12
3 4 11 9 10 15 5 1 2 14 12 6 13 8 7 δ2 δ1
3 4 11 9 10 15 5 1 2 14 12 6 13 8 7 δ2 δ3
3 4 11 9 10 15 5 1 2 14 12 6 13 8 7 δ3
n
i=1
n
i=1
n
i=1