Closest Pair Of Points Algorithm

The nearest pair of points problem or nearest pair problem is a problem of computational geometry: given N points in metric space, find a pair of points with the smallest distance between them. It turns out that the problem may be solved in O(n log N) time in a euclidean space or Lp space of fixed dimension d. In the algebraic decision tree model of calculation, the O(n log N) algorithm is optimal, by a reduction from the component uniqueness problem.

Closest Pair Of Points source code, pseudocode and analysis