No. The minimum distance between all points in O (n ^ 2), because you have to compare each point with every other point. Technically, this is n * n / 2, because you only need to fill in half the matrix.
There are faster algorithms for finding the nearest neighbor at a given point. Unfortunately, you have to do this for each point in order to find the next two points.
source
share