Given a binary Tree, check whether the tree is symmetric or not
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Symmetric tree
A binary tree is said to be symmetric, if a vertical axis through the root cuts the tree in two mirror subtrees. That means the right child & left child of root are two mirror trees.
Algorithm:
Earlier, we have discussed how two check mirror trees? Kindly refer there for more detailed analysis.
In this case we are to check whether the tree is symmetric or not, which can be done via checking whether root's children are mirror trees or not?
Example with explanation
C++ implementation
Output