@rahul : i dont think so , i guess what u are telling will be like creating
mirror image of the tree.

On Wed, Dec 21, 2011 at 6:23 AM, rahul <[email protected]> wrote:

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