Calculate sum' create heap extract first k elements. On Tue, Jul 19, 2011 at 6:31 PM, Rishabh Maurya <[email protected]>wrote:
> > > find distances of given point P(x,y) with all other points in O(n) and > build initial Max-Heap of K elements with key as distance calculated. > > Now compare all remaining points with the root of the heap . If its > distance is less then key of root then just change the root node and its key > and perform max-heapify . If not so leave the heap as it is and process next > remaining point. > > Finally Heap will contain K elements which are closest to point P. > > So in short complexity is O(NLog(K)) > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
