How to find two most distant points?

For this specific problem, with just a list of Euclidean points, one way is to find the convex hull of the set of points. The two distant points can then be found by traversing the hull once with the rotating calipers method.

Here is an O(N log N) implementation:

  • http://mukeshiiitm.wordpress.com/2008/05/27/find-the-farthest-pair-of-points/

If the list of points is already sorted, you can remove the sort to get the optimal O(N) complexity.


For a more general problem of finding most distant points in a graph:
Algorithm to find two points furthest away from each other

The accepted answer works in O(N^2).

Leave a Comment

tech