What is the maximum height of any AVL-tree with nodes? Assume that the height of a tree with a single node is .
View worked solution
Answer: B
To find the maximum height of an AVL tree with nodes, we can determine the minimum number of nodes required to construct an AVL tree of height , denoted as .
Given that the height of a single-node tree is :
- For : (a single root node)
- For : (a root with one child)
For any height , an AVL tree of minimum size consists of a root, one subtree of height with minimum nodes, and another subtree of height with minimum nodes. This gives the recurrence relation:
Using this recurrence, we compute the minimum nodes for successive heights:
Since we have exactly nodes, the maximum height we can achieve is (which requires exactly nodes). A height of would require at least nodes.
Thus, the maximum height of an AVL tree with nodes is 3.
Free practice · Your answers on this page are not saved.
