What is the maximum height of any AVL tree with 7 nodes? Assume that height of…
2017
What is the maximum height of any AVL tree with 7 nodes? Assume that height of tree with single node is 0.
- A.
2
- B.
3
- C.
4
- D.
5
Attempted by 336 students.
Show answer & explanation
Correct answer: B
To find the maximum height of an AVL tree with 7 nodes, we use the minimum node count recurrence relation: N(h) = N(h-1) + N(h-2) + 1. Starting with base cases N(0)=1 and N(1)=2, we calculate: N(2) = 4, N(3) = 7. Since an AVL tree of height 3 requires a minimum of exactly 7 nodes, and height 4 would require at least 12 nodes, the maximum possible height with 7 nodes is 3.
A video solution is available for this question — log in and enroll to watch it.