Check If One Binary is Mirror Tree of another Binary Tree.

Objective: – Given two binary trees check if they are a mirror images of each other.

Example:

Check-If-One-Binary-is-Mirror-Tree-of-another-Binary-Tree
Check-If-One-Binary-is-Mirror-Tree-of-another-Binary-Tree

Approach:

  • Do the preorder traversal on both the trees simultaneously.
  • if any node doesn’t have a corresponding node in another tree, return false.
  • check if the left node in one tree is the right node in another tree and vice versa.

Code:

Is Mirror Trees : true

3 thoughts on “Check If One Binary is Mirror Tree of another Binary Tree.”

Leave a Reply to Shilpi Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.