Closest Pair of Points

D&C for computational geometry.

Problem: Given nn points in 2D, find the closest pair.

Brute force: Check all pairs. O(n2)O(n^2).

D&C approach: 1.1. Sort points by xx-coordinate.

2.2. Divide: Split into left and right halves by xx.

3.3. Conquer: Recursively find closest pair in each half.

4.4. Combine: Check pairs crossing the dividing line within a strip of width 2d2d (where dd is the min from both halves).

The strip check: Sort strip points by yy. For each point, only check the next 77 points (geometry limits candidates).

Time: O(nlog2n)O(n \log^2 n) with careful implementation (can be O(nlogn)O(n \log n) with optimization).