On 09-Dec-2010, at 1:28 PM, rajan goswami wrote:

> 1.  
> Below is a solution of first problem - 
> 
> int SuccessorOfANodeInBST(Node N, int givenNumber)
> {
>     if(N->rightChild != NULL)
>            return (int) N->rightchild->data;

Why this? The right child might not be the next immediate higher number after 
givenNumber in the tree.


>     
>    int iNumberFound = 0;
>    Node K = ParentOf(N);
>    Node J  = ParentOf(K);
> 
>    while(1)   
>    {
>       if(K == J->leftChild)
>       {
>            iNumberFound = (int) J->data;
>            break;
>       }
>       K = J;
>       J  = ParentOf(K);
>    } 
>    return iNumberFound;     
> }
> 
> Rajan.
> 
> On Thu, Dec 9, 2010 at 1:25 PM, Anand <anandut2...@gmail.com> wrote:
> You are given a binary tree. and You need to design a function which takes 
> any node from the binary search tree and a number.
>  
> Function should be able to return next higher number in binary search tree 
> from the given node of binary search tree.
>  
> Next higher number means : You given a number. you need to find next higher 
> number of that number in a binary search tree if it exist.
>  
> I hope this makes it clear.
>  
> 
> 
>  
> On Wed, Dec 8, 2010 at 11:27 PM, sahil gujral <gujralsa...@gmail.com> wrote:
> explain the 1st one again
> 
> 
> On Thu, Dec 9, 2010 at 11:16 AM, Anand <anandut2...@gmail.com> wrote:
> One of my friend recently had a telephonic interview and he got two question 
> to program.
>  
> 1. Given a binary search tree. Write a function which takes any given node 
> from the binary tree and a number.
>     Functin has to return the next highest number of the given number from 
> the binary search tree.
>  
> 2. You have given a structure which has two member, One which stores the time 
> and other stores the function pointer
>     Your function has to call the function stored in the fuction poitner 
> after the time given in the structure elapses.
>      Design that function?
>  
>  
> let me know in case if the questions are not clear in any way.
>  
>  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 algoge...@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.

--
Shuaib
http://www.bytehood.com




-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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