Buttercola: LinkedIn: K Nearest points on a plane
LinkedIn: K Nearest points on a plane
Question:
Given a list of points and a central point, find the k nearest points from the central point.
Solution:
Use a max heap. First store the first K points into the heap. Then compare the distance between the current point and the max point. If less than the max value, then poll out the max and add the current point into the heap.
Given a list of points and a central point, find the k nearest points from the central point.
Solution:
Use a max heap. First store the first K points into the heap. Then compare the distance between the current point and the max point. If less than the max value, then poll out the max and add the current point into the heap.
Read full article from Buttercola: LinkedIn: K Nearest points on a plane
No comments:
Post a Comment