How do you represent the N-ary tree? If you represent child nodes as a
list, reversing this child node list at each node will solve the
problem right? I may be wrong.

On Dec 20, 10:50 am, atul anand <atul.87fri...@gmail.com> 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 <ankurga...@gmail.com> 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 
> > <shashank7andr...@gmail.com>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 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.

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