I have to make a efficient algorithm that gets two point that are the most distant from each other and I am trying to get the O(nlogn) complexity. I searched for an efficient algorithm, but all I could find is for the closest points.
The output should just print the 2 points.
What I found by now is this algorithm from GeeksForGeeks : https://www.geeksforgeeks.org/closest-pair-of-points-using-divide-and-conquer-algorithm/ but is for the closest points.
And this solution:
mukeshiiitm.wordpress.com/2008/05/27/find-the-farthest-pair-of-points/
that looks way to complicated for a homework.
First method, looks weird, plus I don't think it works for my problem.
Any help would be appreciated.
Well this is homework so no code examples :)
Here's O(n log n) approach:
Find Convex Hull of all given points using any of O(n log n) convex hull algorithms
Now we can notice that 2 farthest points will still be on convex hull
We can find such points using Rotating calipers technique in O(n) time