apply BFS
the node after the particular node(whode cousin to be find) will be the
required node

On Wed, Aug 10, 2011 at 2:15 PM, Puneet Chawla <puneetchawla...@gmail.com>wrote:

>
> Agree with mohit goel..
>
> On Wed, Aug 10, 2011 at 11:22 AM, Mohit Goel <mohitgoel291...@gmail.com>wrote:
>
>>                        10
>>              4                      5
>>        2          7          6         11
>>    1     3    9   8     12  13   14   15
>>
>>
>> i think we should first  find the parent of the particular node ..then
>> apply the concept as told by Brijesh on it ....
>>
>> p =parent(q);
>> r = parent(p);
>> count =1;
>> while(p ==isright(r))
>> {
>> p=r;
>> r=parent(r);
>> count++;
>> if(r==root)
>> break;
>>
>> }
>>
>> if(d =right(r))
>> {
>> while(count!=0)
>> {
>> if(d->left)
>> d=d->left;
>> else d=d->right;
>> count--;
>> }
>> }
>> else return NULL;
>> o/p=d->value;
>>
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@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.
>>
>
>
>
> --
> With regards
>   ............
> Puneet Chawla
> Computer Engineering Student
> NIT Kurukshetra
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@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 algogeeks@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