Recall & Review
beginner
What is the height of a binary tree?
The height of a binary tree is the number of edges on the longest path from the root node to a leaf node. If the tree has only one node, its height is 0.
Click to reveal answer
beginner
How do you calculate the height of a binary tree recursively?
Calculate the height of the left subtree and the right subtree recursively, then the height of the tree is 1 plus the maximum of these two heights.
Click to reveal answer
beginner
What is the height of an empty binary tree?
The height of an empty binary tree is defined as -1 because there are no nodes.
Click to reveal answer
beginner
Why is the height of a single-node binary tree 0?
Because the height counts edges on the longest path from root to leaf, and a single node has no edges, so height is 0.
Click to reveal answer
intermediate
What is the time complexity of computing the height of a binary tree?
The time complexity is O(n), where n is the number of nodes, because each node is visited once during the height calculation.
Click to reveal answer
What is the height of a binary tree with only one node?
✗ Incorrect
A single node has no edges, so height is 0.
What is the height of an empty binary tree?
✗ Incorrect
By definition, an empty tree has height -1.
Which method is commonly used to find the height of a binary tree?
✗ Incorrect
Height is usually found by recursively calculating the depth of subtrees.
If left subtree height is 3 and right subtree height is 5, what is the height of the tree?
✗ Incorrect
Height = 1 + max(left height, right height) = 1 + 5 = 6.
What is the time complexity to compute the height of a binary tree with n nodes?
✗ Incorrect
Each node is visited once, so time complexity is O(n).
Explain how to find the height of a binary tree using recursion.
Think about how you break down the problem into smaller parts.
You got /3 concepts.
Describe the difference between the height of an empty tree and a single-node tree.
Consider what height means in terms of edges.
You got /3 concepts.