Check if Two Trees are Symmetric
📖 Scenario: Imagine you have two family trees represented as binary trees. You want to check if these two trees are mirror images of each other, meaning they are symmetric around their center.
🎯 Goal: Build a program that creates two binary trees, sets up a helper function to check symmetry, and then uses this function to determine if the two trees are symmetric.
📋 What You'll Learn
Create two binary trees with exact node values
Create a helper function called
isMirror that checks if two trees are mirror imagesCreate a function called
areSymmetric that uses isMirror to check symmetryPrint
true if the trees are symmetric, otherwise false💡 Why This Matters
🌍 Real World
Checking if two trees are symmetric is useful in graphics, data validation, and comparing hierarchical data structures.
💼 Career
Understanding tree symmetry helps in coding interviews and software roles involving tree data structures and recursion.
Progress0 / 4 steps