How come it just reversed the root? I still dont get it!

Rahul

On Feb 9, 7:57 pm, Don <dondod...@gmail.com> wrote:
> It appears to be an attempt to reverse the tree. However, there is a
> problem. It reverses the left sub-tree, then swaps the left and right
> sub-trees. Then it reverses the right sub-tree. But wait! The original
> left sub-tree which we reversed is now the right sub-tree, so we
> actually unreversed it. And the left sub-tree has never been reversed
> at all. So I don't think that it will work. The actual result will be
> that left and right will be swapped in the root node. Beyond that,
> there will be no change.
>
> To make it work as intended, either do the two recursive calls one
> after the other, or change the second one from Right to Left.
>
> Don
>
> On Feb 9, 8:38 am, Rahul Menon <menonrahul1...@gmail.com> wrote:
>
>
>
>
>
>
>
> > What does this function do?
>
> > void function(Node **node){
> >         if(*node!=NULL){
> >                 function(&(*node)->Left);
> >                 Node *temp;
> >                 temp = (*node)->Left;
> >                 (*node)->Left= (*node)->Right;
> >                 (*node)->Right = temp;
> >                 function(&(*node)->Right);
> >         }
>
> > }- Hide quoted text -
>
> > - Show quoted text -

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