Java

Write a program to find given two trees are mirror or not in Java2 min read

Write a simple program to identify given two binary trees are mirrored image of each other. Here is an example image of mirrored trees:

Write a program to find given two trees are mirror or not in Java
Write a program to find given two trees are mirror or not in Java

Here are the steps to find out mirrored binary trees:

  1. If both given trees root node values are same.
  2. Left subtree of root of first tree is mirror of right subtree of root of second tree.
  3. Right subtree of root of first tree is mirror of left subtree of root of second tree.




Output:

Leave a Comment