|
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| |
Running
time recurrence
|
|
|
|
T(n) =
2T(n/2) + n log n
|
|
|
|
and
T(1) = 1
|
|
|
|
This
does not solve to
|
|
|
|
T(n) =
O(n log n)
|
|
|
| |
Final
trick: Presorting
|
|
|
|
|
Sort
the set of points by y-
|
|
|
|
coordinate
before we start
|
|
|
|
|
Whenever
we split a point
|
|
|
|
set,
we can run through the
|
|
|
list
sorted by y-coordinate
|
|
|
|
and
create a new list for
|
|
|
|
each
part, sorted by y-
|
|
|
|
coordinate
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| |
Recurrence
becomes
|
|
|
|
T(n) =
2T(n/2) + n
|
|
|
|
and
T(1) = 1
|
|
|
| |
Solution:
T(n) = O(n log n)
|
|
|
| |
Its
possible to show that the
|
|
|
closest
pair can be found in
|
|
|
|
O(n
log n) time for any
|
|
|
dimension
|
|
|
|