Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fastest way to find minimum distance between points

I have a set of 2D points and need to find the fastest way to figure out which pair of points has the shortest distance in the set.

What is the optimal way to do this? My approach is to sort them with quicksort and then calculate the distances. This would be O(nlogn + n) = O(nlogn).

Is it possible to do it in linear time?

Thanks.


1 Answers

It is actually:

The closest pair of points problem or closest 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...

In the computational model which assumes that the floor function is computable in constant time the problem can be solved in O(n log log n) time. If we allow randomization to be used together with the floor function, the problem can be solved in O(n) time..

like image 105
leiz Avatar answered Nov 26 '25 23:11

leiz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!