Loading...
Visualize how recursive splitting + strip filtering reduces comparisons from O(n^2) to O(n log n). Follow each phase step-by-step.
Only next ~7 y-neighbors can improve delta.
1function closestPair(points):2 sort points by x3 return recursive(points)4function recursive(P):5 if |P| <= 3: return bruteForce(P)6 mid = |P|/2; L = P[0:mid]; R = P[mid:]7 d = min(recursive(L), recursive(R))8 strip = points within d of mid line9 return min(d, stripClosest(strip, d))