Overview
The classic closest-pair algorithm sorts points, divides the plane, and checks only a narrow strip around the split after solving both halves.
Finds the two points with the smallest distance between them.
Compact metadata for implementation and discovery.
The classic closest-pair algorithm sorts points, divides the plane, and checks only a narrow strip around the split after solving both halves.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n log n)
Average
O(n log n)
Worst
O(n log n)
Space
O(n)
distance(a, b) = sqrt((a.x - b.x)^2 + (a.y - b.y)^2)Measures the separation minimized by the algorithm.
Show the split line and narrow strip where cross-boundary closest pairs can appear.
Keeping points sorted by y coordinate avoids extra sorting in each recursive call.
What each reference supports for this entry.
Computational geometry textbook support for Closest Pair of Points's geometric model, data structures, and robustness concerns.
Open sourceAlgorithm catalog support for Closest Pair of Points's problem context, known alternatives, and practical selection tradeoffs.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Closest-pair algorithms and k-d trees are different approaches to nearest-neighbor-style geometry queries.