Data Structures & AlgorithmsHardProduct-company MCQ pattern

What is the maximum possible height of an AVL tree with 20 nodes (a single node has height 0)?

  1. A. 6
  2. B. 5
  3. C. 19
  4. D. 4

Correct answer: B. 5

The fewest nodes for height h are N(h) = N(h − 1) + N(h − 2) + 1: 1, 2, 4, 7, 12, 20, 33. Since N(5) = 20 ≤ 20 < N(6) = 33, the maximum height is 5. ⌊log₂ 20⌋ = 4 is the minimum height, not the maximum.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic