A Divide & Conquer Algorithm for
Closest Pair of Points
ClosestPair (pointSet):
Split pointSet in half with a
vertical line so that half are
on left and half are on right;
Recursively determine closest
pair in each half;
Let d be smallest of these two
distances;
Search along the boundary
between the two halves to
see if there are any pairs
closer than d;
Analysis
The last step appears to
require time O(n2)
Recurrence for total time is
T(n) = 2T(n/2) + n2
and T(1) = 1
Solution: T(n) = O(n2)
The algorithm’s last step is
the problem
How can we do the last step
in linear time?
CS409 - Spring 2000
10