It is, but it depends on representation of that tree

if you have left and right child, and father, pointers.

Then the algorithm is:
if you are left child of father, then, use the right child of your father.
but if you are right child you need to go at least 2 parents up, in good
case you go 2 nodes up, ,then to right down, and then one step down left.

in general case, you go k-times up, until you are left children, then you go
once more up, then one step to right down and k steps left down.
but it only works if the tree is complete.
And if you reach root of the tree, you go k+1 times to left down.

why you need that algorithm?
If you cen know the deepest node of the subtree, maybe something is
possible.

2009/1/20 sharad kumar <aryansmit3...@gmail.com>

> so u want to do bfs to get laers ...but there should be alternate solution
> na.....
>
>
> On Tue, Jan 20, 2009 at 8:45 PM, Miroslav Balaz 
> <gpsla...@googlemail.com>wrote:
>
>> the bfs goes by layers, so if you have organized nodes into layers, then
>> the it is the next node on that lay
>> er, or the first node of next layer
>> 2009/1/19 sharad kumar <aryansmit3...@gmail.com>
>>
>>
>>> could somebody pls tell me how to find bfs sucessor of a node in a
>>> tree (BST as well as binary)
>>>
>>>
>>
>>
>>
>
> >
>

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

Reply via email to