Source: AMAZON INTERVIEW QUESTION
Given a point P and other N points in two dimensional space, find K points
For just a single query...
Maintain a heap of size k.
k
For each point, calculate the distance to the point P. Insert that distance into the heap and delete the maximum from the heap if the size of the heap is greater than k.
P
Running time: O(n log k)
O(n log k)