ALGO:
1. For each element 1 to k:
insert in into min-heap
2. for each element k+1 to n
delete the root of min-heap and insert this item into the min-
heap
3. Finally you have a min-heap of k largest numbers and the root is
your answer
COMPLEXITY: O(n logn)
-Monish
On Sep 3, 3:03 pm, teja bala <[email protected]> wrote:
> //Asked in MS please help me with the coding or Give an algorithm
>
> Write code to return the kth largest element in a tree ...>>> function
> prototype is int fucnkth(node *root,int 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.