@anup,@sukran ithink u both are right in case of binary search tree... we can traverse and then easily find the value... but in case of heap first we have to create the heap and accordingly apply the algo the create min heap..... it will be the complex program.... so simple is bst just traverse by inorder and compare if anyone has simple solution or any other case then plz tell.....
On Sun, Sep 4, 2011 at 9:56 PM, monish001 <[email protected]> wrote: > 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. > > -- 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.
