我有一组二维点,并需要找到最快的方式找出哪些点对具有集合的最短距离。
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.
什么是做到这一点的最佳方法是什么?我的做法是对它们进行排序与快速排序,然后计算出距离。这将是O(nlogn + N)= O(nlogn)。
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?
感谢。
它实际上是的http:// EN .wikipedia.org /维基/ Closest_pair_problem
上一篇:有效地写一个航空公司路由算法有效地、航空公司、路由、算法
下一篇:算法分组算法