Given a binary tree, Convert it into its Mirror Tree
Objective: Given a binary tree, Convert it into its Mirror Tree
Mirror Tree: Mirror Tree of a binary tree is where left and right child of every node of given binary tree is interexchanged.
Input: A binary tree.
- Do the PreOrder Traversal.
- Starting from the root, swap the left and right childs.
- Recursively call the same procedure in the leftsubtree and right subtree.
1 2 3 4 5 6 7 Mirror Image 7 6 5 4 3 2 1
Top Companies Interview Questions..-
If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.