Recall & Review
beginner
What does it mean for two trees to be symmetric?
Two trees are symmetric if one is a mirror reflection of the other. This means the left subtree of one tree matches the right subtree of the other, and vice versa.
Click to reveal answer
beginner
What is the base case when checking if two trees are symmetric?
If both trees are empty (null), they are symmetric. If only one is empty, they are not symmetric.
Click to reveal answer
intermediate
How do you compare nodes when checking tree symmetry?
Compare the values of the current nodes. Then recursively check if the left child of one tree is symmetric with the right child of the other tree, and vice versa.
Click to reveal answer
intermediate
Why is recursion useful for checking tree symmetry?
Recursion naturally explores both trees at the same time, comparing corresponding nodes and their children in a mirrored way, making the code simple and clear.
Click to reveal answer
intermediate
What is the time complexity of checking if two trees are symmetric?
The time complexity is O(n), where n is the number of nodes in the trees, because each node is visited once during the comparison.
Click to reveal answer
What should you check first when comparing two trees for symmetry?
✗ Incorrect
If both nodes are null, they are symmetric at this point. This is the base case for recursion.
When checking symmetry, which pairs of nodes do you compare recursively?
✗ Incorrect
Symmetry means the left subtree of one tree matches the right subtree of the other, so compare left child of one with right child of the other.
If one node is null and the other is not, what does that mean for symmetry?
✗ Incorrect
If one node is null and the other is not, the trees differ in structure and are not symmetric.
What is the main idea behind the recursive function to check symmetry?
✗ Incorrect
The function compares nodes in mirrored positions to verify symmetry.
What happens if the root values of the two trees are different?
✗ Incorrect
If root values differ, trees cannot be symmetric.
Explain how to check if two trees are symmetric using recursion.
Think about mirror positions and base cases.
You got /4 concepts.
Describe the time complexity and why it is that way when checking tree symmetry.
Consider how many nodes you compare.
You got /3 concepts.