Unformatted text preview: ¢ Suffices to look at points in
the 2kwidth strip around the
median line k2
k1 Divide & Conquer
Scanning the strip
ā¢ Sort all points in the strip
by their ycoordinates,
forming q1ā¦qr, r n.
ā¢ Let yi be the ycoordinate
of qi
ā¢ For i=1 to r
ā j=i1
ā While yiyj < d ā¢ Check the pair qi,qj
ā¢ j:=j1 d Analysis  Analysis
Divide & Conquer
ā¢ Correctness: easy
ā¢ Running time is more
involved
ā¢ Can we have many
qjās that are within
distance k from qi ?
ā¢ No
ā¢ Proof by packing
argument
October 30, 2003 Lecture 17: Closest Pair k 6 Divide & Conquer  Analysis
Analysis, ctd.
Theorem: there are at most 7
qjās such that yiyj k.
Proof:
ā¢ Each such qj must lie either
in the left or in the right k! k
square
ā¢ Within each square, all
points have distance
distance k from others
ā¢ We can pack at most 4 such
points into one square, so
we have 8 points total (incl.
qi) qi Divide & Conquer  Analysis Packing bound
ā¢ Proving ā4ā is not obvious
ā¢ Wi l l p r o v e ā 5 ā
ā Draw a disk of radius k/2
around each point
ā Disks are disjoint
ā The disksquare intersection
has area
(k/2)2/4 = /16 k2
ā The square has area k2
ā Can pack at most 16/
5.1
points Divide & Conquer  Analysis
Running time
ā¢ Divide: O(n)
ā¢ Combine: O(n log n) because we sort by y
ā¢ However, we can:
ā Sort all points by y at the beginning
ā Divide preserves the yorder of points
Then combine takes only O(n) ā¢ We get T(n)=2T(n/2)+O(n), so
T(n)=O(n log n)...
View
Full
Document
This note was uploaded on 01/15/2012 for the course COT 5405 taught by Professor Ungor during the Fall '08 term at University of Florida.
 Fall '08
 UNGOR
 Algorithms, Data Mining, Databases

Click to edit the document details