Click or tap the plane to add a point. Orange line = current dividing line, violet band = strip of half-width δ.
Find the pair minimising d(p,q)=sqrt((px-qx)^2+(py-qy)^2). Brute force tests n(n-1)/2 pairs: O(n^2).
Divide and conquer (Shamos and Hoey, 1975): sort by x, split at the median, solve each half, set δ=min(δL,δR). Any closer straddling pair lies in the strip |x-xm|<δ; sorted by y, each strip point needs comparing only with followers less than δ away in y, a constant number by a packing argument. T(n)=2T(n/2)+O(n) gives O(n log n) comparisons (this page re-sorts the strip per call, so run time is O(n log^2 n)).
A grid of cell size equal to an upper bound on d solves it in expected O(n); here it is only an independent cross-check. Simplifications: exact doubles, strict inequality for ties; counts are distance evaluations, not clock time.