Recall & Review
beginner
What does it mean for a binary tree to be balanced?
A binary tree is balanced if for every node, the height difference between its left and right subtrees is at most 1.
Click to reveal answer
beginner
What is the main idea behind checking if a binary tree is balanced?
We check the height of left and right subtrees for every node and ensure their difference is not more than 1.
Click to reveal answer
intermediate
Why is it efficient to check balance and height in the same recursion?
Because it avoids repeated height calculations, reducing time complexity from O(n²) to O(n).
Click to reveal answer
intermediate
What does a return value of -1 usually indicate in a balanced tree check function?
It indicates that the subtree is not balanced, so the whole tree is unbalanced.
Click to reveal answer
beginner
In JavaScript, how can you represent a binary tree node?
A node can be an object with properties: value, left (child), and right (child). Example: { value: 5, left: null, right: null }
Click to reveal answer
What is the maximum allowed height difference between left and right subtrees for a node to be balanced?
✗ Incorrect
A balanced binary tree requires the height difference to be at most 1.
Which approach is best to check if a binary tree is balanced efficiently?
✗ Incorrect
Using one recursive function that returns height or -1 avoids repeated calculations.
If a subtree is unbalanced, what should the recursive function return to stop further checks?
✗ Incorrect
Returning -1 signals unbalanced subtree and stops further recursion.
What is the time complexity of the efficient balanced tree check algorithm?
✗ Incorrect
The efficient algorithm visits each node once, so time complexity is O(n).
In JavaScript, which property is NOT typically part of a binary tree node?
✗ Incorrect
Parent is not always stored; usually nodes have value, left, and right.
Explain how to check if a binary tree is balanced using recursion.
Think about returning height or a special value to indicate imbalance.
You got /5 concepts.
Describe why checking balance and height in one recursive function is better than separate calls.
Consider how many times each node is visited.
You got /4 concepts.