# An*O*(*n* log*n*) algorithm for the all-nearest-neighbors Problem

- First Online:

- Received:
- Revised:

DOI: 10.1007/BF02187718

- Cite this article as:
- Vaidya, P.M. Discrete Comput Geom (1989) 4: 101. doi:10.1007/BF02187718

- 74 Citations
- 930 Views

## Abstract

Given a set*V* of*n* points in*k*-dimensional space, and an*L*_{q}-metric (Minkowski metric), the all-nearest-neighbors problem is defined as follows: for each point*p* in*V*, find all those points in*V*−{*p*} that are closest to*p* under the distance metric*L*_{q}. We give an*O*(*n* log*n*) algorithm for the all-nearest-neighbors problem, for fixed dimension*k* and fixed metric*L*_{q}. Since there is an Θ(*n* log*n*) lower bound, in the algebraic decision-tree model of computation, on the time complexity of any algorithm that solves the all-nearest-neighbors problem (for*k*=1), the running time of our algorithm is optimal up to a constant factor.