1.
Below is a solution of first problem -

int SuccessorOfANodeInBST(Node N, int givenNumber)
{
    if(N->rightChild != NULL)
           return (int) N->rightchild->data;

   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 <[email protected]> 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 <[email protected]>wrote:
>
>> explain the 1st one again
>>
>>
>>   On Thu, Dec 9, 2010 at 11:16 AM, Anand <[email protected]> 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 [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<algogeeks%[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]<algogeeks%[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]<algogeeks%[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.

Reply via email to