[algogeeks] Re: algo for mirror a tree
assuming its a binary tree Node* mirror(Node* root){ if(root==NULL) return; Node* mirrorLeft = mirror(root->left)' Node* mirrorRight = mirror(root->right); root->left = mirrorRight; root->right=mirrorLeft; return root; } On Mar 11, 4:50 am, AKS wrote: > can u elaborate a bit ?? > with sm example if possible > > On Mar 11, 4:52 am, priyank desai wrote: > > > > > > > > > Do a post order traversal of the tree and swap its child instead of > > printing the node values. > > > On Mar 10, 8:19 am, Subhransupanigrahi > > wrote: > > > > Hey guys, > > > you guys have came across many time with mirror a tree. if anyone has > > > effective ways interms of memory & efficiency way to implement mirror of > > > a tree. > > > > Sent from my iPhone -- 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.
[algogeeks] Re: algo for mirror a tree
can u elaborate a bit ?? with sm example if possible On Mar 11, 4:52 am, priyank desai wrote: > Do a post order traversal of the tree and swap its child instead of > printing the node values. > > On Mar 10, 8:19 am, Subhransupanigrahi > wrote: > > > > > > > > > Hey guys, > > you guys have came across many time with mirror a tree. if anyone has > > effective ways interms of memory & efficiency way to implement mirror of a > > tree. > > > Sent from my iPhone -- 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.
[algogeeks] Re: algo for mirror a tree
Do a post order traversal of the tree and swap its child instead of printing the node values. On Mar 10, 8:19 am, Subhransupanigrahi wrote: > Hey guys, > you guys have came across many time with mirror a tree. if anyone has > effective ways interms of memory & efficiency way to implement mirror of a > tree. > > Sent from my iPhone -- 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.