You are given a list of points on the plane, write a program that displays each point along with the three other points that are closest to it. These three points are ordered by distance.
For example, given the set of points where each line has the form: ID x-coordinate y-coordinates
1 0.0 0.0 2 10.1 -10.1 3 -12.2 12.2 4 38.3 38.3 5 79.99 179.99
Your program should output:
1 2,3,4 2 1,3,4 3 1,2,4 4 1,2,3 5 4,3,1
This is an interview question that I found on an online forum. I can think of an O (n * n) solution: calculate the distance of each point to every other point. Return the minimum distance points for this point. Repeat process for other points
source share