Data Structures & AlgorithmsHardGATE CS · Product-company placement
What is the minimum possible number of nodes in an AVL tree of height 5? (Height counts edges on the longest root-to-leaf path, so a single node has height 0; in an AVL tree the two subtrees of every node differ in height by at most one.)
- A. 21
- B. 63
- C. 19
- D. 20
Correct answer: D. 20
A minimum AVL tree of height h has a root with subtrees of heights h − 1 and h − 2, so N(h) = N(h − 1) + N(h − 2) + 1 with N(0) = 1 and N(1) = 2. The +1 for the root is what the trap options drop.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- What is the minimum possible number of nodes in an AVL tree of height 6? (Height counts edges on the longest root-to-leaf path, so a…
- What is the minimum possible number of nodes in an AVL tree of height 7? (Height counts edges on the longest root-to-leaf path, so a…
- What is the minimum possible number of nodes in an AVL tree of height 8? (Height counts edges on the longest root-to-leaf path, so a…
- What is the minimum possible number of nodes in an AVL tree of height 9? (Height counts edges on the longest root-to-leaf path, so a…
- A tree on vertices 0 to 9 has the edges 1-0, 2-0, 3-1, 4-1, 5-4, 6-5, 7-6, 8-0, 9-7. What is its diameter, meaning the largest number of…
- A tree on vertices 0 to 9 has the edges 1-0, 2-0, 3-0, 4-0, 5-4, 6-2, 7-4, 8-5, 9-2. What is its diameter, meaning the largest number of…