@gaurav : you need to first build heap and then maintain heap property ever time you remove element.so this would take O(n logn ).
On Wed, Dec 14, 2011 at 1:38 AM, Gaurav Kumar <[email protected]> wrote: > Why can't we keep removing the minimum element each time and compare it > with x? This should take O(k) time since in a Min heap, the minimum element > can be removed in O(1) time? Am I missing something? > > > On Tue, Dec 13, 2011 at 8:43 AM, atul anand <[email protected]>wrote: > >> O(k) in the worst-case , then i guess it would better to use >> median-of median algo to find element at rank k. and comparing with x. >> >> or >> we can us hashtable to solve this. >> >> On Tue, Dec 13, 2011 at 3:23 PM, Ankur Garg <[email protected]> wrote: >> >>> Given an array-based heap on n elements and a real number x, efficiently >>> determine whether the kth smallest element in the heap is greater than or >>> equal to x. Your algorithm should be O(k) in the worst-case, independent of >>> the size of the heap. >>> >>> >>> This question was also asked in Amazon >>> >>> -- >>> 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. >>> >> >> -- >> 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. >> > > -- > 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. > -- 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.
