Question: Given a 2 binary trees root nodes, check if the structure is mirror to each other.
Fantastic news! We've Found the answer you've been seeking!
Question:
Question:
Given a 2 binary trees root nodes, check if the structure is mirror to each other.
Example:
Consider the image given below and its mirror.
Check if Two Trees are Mirror Structure to each other
If you can see in the above image, both the trees structure are mirror to each other.
We don’t consider the node elements, we just consider the structure.
So to solve this problem, we need to check if right node is present in tree 1, then left node should be present in tree 2 and vice versa.
By doing so we can check if both of the trees have mirror structure.
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date: