This post is completed by 2 users
|
Add to List |
68. Transforming a Binary Tree into its Mirror Image
Objective: Given a binary tree, Convert it into its Mirror Tree
Mirror Tree: The mirror Tree of a binary tree is where the left and right children of every node of a given binary tree are interchanged.
Example:
Approach:
- Do the PreOrder Traversal.
- Starting from the root, swap the left and right children.
- Recursively call the same procedure in the left subtree and right subtree.
Output:
1 2 3 4 5 6 7 Mirror Image 7 6 5 4 3 2 1