Recall & Review
beginner
What does it mean for two binary trees to be symmetric?
Two binary trees are symmetric if one is a mirror reflection of the other. This means the left subtree of one tree is the mirror of the right subtree of the other tree, 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 (nil), they are symmetric. If only one is empty, they are not symmetric.
Click to reveal answer
beginner
In Go, how do you define a simple binary tree node struct?
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
Click to reveal answer
intermediate
What recursive checks are done to confirm two trees are symmetric?
Check if the current nodes have the same value, then recursively check if the left subtree of the first tree is symmetric with the right subtree of the second tree, and the right subtree of the first tree is symmetric with the left subtree of the second tree.
Click to reveal answer
intermediate
Why is recursion a good approach to check tree symmetry?
Because symmetry involves comparing subtrees in a mirrored way, recursion naturally allows checking smaller parts of the trees step-by-step until the base cases are reached.
Click to reveal answer
What should you return if both input trees are nil when checking symmetry?
✗ Incorrect
If both trees are empty, they are symmetric by definition.
Which pairs of subtrees do you compare to check symmetry?
✗ Incorrect
Symmetry means left subtree of one tree matches right subtree of the other tree.
What is the first step in the recursive function to check symmetry?
✗ Incorrect
First check if both nodes are nil to handle base case.
If one node is nil and the other is not, what should the function return?
✗ Incorrect
Trees are not symmetric if one node is missing and the other is present.
What Go data type is used to represent a tree node pointer?
✗ Incorrect
Pointers to TreeNode struct are used to link nodes in Go.
Explain how you would check if two binary trees are symmetric using recursion.
Think about mirror images and how left and right subtrees relate.
You got /4 concepts.
Write the Go struct definition for a binary tree node and describe its fields.
Use type TreeNode struct with int and pointers.
You got /3 concepts.