@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 <gkuma...@gmail.com> 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 <atul.87fri...@gmail.com>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 <ankurga...@gmail.com> 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 algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> 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 algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> 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 algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to