it would be better if we insert values in array in while loop and then
outside call  makeheapk() and then return topheap();
this will reduce the heap making complexity.
On Sun, Sep 4, 2011 at 2:29 PM, mohit verma <[email protected]> wrote:

> int funkth(node *root,int k)
> {
>
>        queue<node *> q;
>      q.insert(root);
> node *temp;
>   while(!q.empty())
>     {
>           temp=q.top();
>           q.pop();
>           if(temp->l) q.insert(temp->l);
>           if(temp->r) q.insert(temp->r);
>           makeheapk(temp->value);  //make  minheap of size k
>    }
>    return topheap();   //return top element of heap
> }
>
> any corrections please?
>
>      On Sun, Sep 4, 2011 at 10:20 AM, sukran dhawan <
> [email protected]> wrote:
>
>> for bst
>> step 1 :count the number of nodes in a tree
>> step2: traverse in inorder.after each node visit decrement n. if n == k
>> then the result
>>
>> On Sun, Sep 4, 2011 at 12:33 AM, 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.
>>
>
>
>
> --
> ........................
> *MOHIT VERMA*
>
>


-- 
........................
*MOHIT VERMA*

-- 
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.

Reply via email to