What is the maximum height of any AVL-tree with 7 nodes? Assume that the…
2009
What is the maximum height of any AVL-tree with 7 nodes? Assume that the height of a tree with a single node is 0.
- A.
2
- B.
3
- C.
4
- D.
5
Attempted by 343 students.
Show answer & explanation
Correct answer: B
Answer: 3
Explanation: Compute the minimum number of nodes N(h) required for an AVL tree of height h using the recurrence N(h) = 1 + N(h-1) + N(h-2), with N(0) = 1 and N(1) = 2. Find the largest h such that N(h) ≤ 7.
N(0) = 1 (single node)
N(1) = 2
N(2) = 1 + 2 + 1 = 4
N(3) = 1 + 4 + 2 = 7
N(4) = 1 + 7 + 4 = 12
Conclusion: Since N(3) = 7 ≤ 7 and N(4) = 12 > 7, the maximum height achievable with 7 nodes is 3.
A video solution is available for this question — log in and enroll to watch it.