Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Pinterest
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Given a binary tree, Convert it into its Mirror Tree

Objec­tive: Given a binary tree, Con­vert it into its Mir­ror Tree

Mir­ror Tree: Mir­ror Tree of a binary tree is where left and right child of every node of given binary tree is interexchanged.

Input: A binary tree.


Mirror Tree

Mir­ror Tree


  • Do the Pre­Order Traversal.
  • Start­ing from the root, swap the left and right childs.
  • Recur­sively call the same pro­ce­dure in the left­sub­tree and right subtree.

Com­plete Code:


1 2 3 4 5 6 7
 Mirror Image  7 6 5 4 3 2 1

You may also like...

  • Gau­rav

    Nice arti­cle. Thanks