This post is completed by 2 users

  • 0
Add to List
Beginner

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:

Mirror Tree

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