@Atul

Even i thought so..but then the definition of leaf node is that its a node
which doesnt have any children...then the answer is root of the original
tree so I got confused here :(



On Wed, Dec 21, 2011 at 12:20 AM, atul anand <[email protected]>wrote:

> @ankur : for the given tree above instead of parent pointing to its child
> , it would be child pointing to its parent after reversing....
> i guess thats wat he is trying to say.
>
>
> On Tue, Dec 20, 2011 at 11:38 PM, Ankur Garg <[email protected]> wrote:
>
>> Hey Shashank
>>
>> Unfortunately I cudnt understand the problem
>>
>> What do u mean by reversing the tree here :(..
>>
>> On Tue, Dec 20, 2011 at 11:23 PM, WgpShashank <[email protected]
>> > wrote:
>>
>>> here is my code
>>>
>>>
>>> List<Node> list=new LinkeList<Node>();
>>>
>>> public List<Node> reverseTreeandReturnListContainingAllLeafNOdes(Node n)
>>> {
>>>        int i=0;
>>>        static int j=0;
>>>
>>>
>>>        if(n==null)
>>>        {
>>>             n=n.children[++j];
>>>             return null;
>>>        }
>>>
>>>        if(n.children[i]==null)
>>>        {
>>>         list.add(n);
>>>
>>>                 return list;
>>>        }
>>>
>>>
>>> list=reverseTreeandReturnListContainingAllLeafNOdes(n.children[i]);
>>>        n.children[i]=n;
>>>
>>>
>>>      return list;
>>> }
>>>
>>> may contains the bug ? any modification / suggestion will be appreciated
>>>
>>> Thanks
>>> Shashank
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/algogeeks/-/2puK42n-1yYJ.
>>>
>>> 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.
>>
>
>  --
> 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.

Reply via email to