We give an algorithm that computes the closest pair in a set of n poin
ts in k-dimensional space on-line, in 0(n log n) time. The algorithm o
nly uses algebraic functions and, therefore, is optimal. The algorithm
maintains a hierarchical subdivision of k-space into hyperrectangles,
which is stored in a binary tree. Centroids are used to maintain a ba
lanced decomposition of this tree.