GATE Computer ScienceHardGATE CS
An AVL tree is a binary search tree in which the heights of the two subtrees of every node differ by at most 1. Taking the height of a single-node tree as 0, what is the maximum possible height of an AVL tree that has exactly 100 nodes?
- A. 9
- B. 7
- C. 10
- D. 8
Correct answer: D. 8
The fewest nodes an AVL tree of height h can have satisfy N(h) = N(h−1) + N(h−2) + 1 with N(0) = 1, N(1) = 2: 1, 2, 4, 7, 12, 20, 33, 54, 88, 143, ... Since N(8) = 88 ≤ 100 < 143 = N(9), the tallest AVL tree with 100 nodes has height 8.
More Algorithms questions
- A B-tree has minimum degree t = 3 (every node other than the root holds between t − 1 and 2t − 1 keys; the root holds at least 1 key) and…
- A DAG has vertices 1 to 8 and edges 1→3, 2→3, 3→4, 3→5, 2→6, 6→5, 4→7, 5→7, 8→6, 1→8. How many different topological orderings does it have?
- A directed graph on vertices 0 to 11 has edges 0→1, 1→2, 2→0, 2→3, 3→4, 4→3, 5→3, 5→6, 6→7, 7→6, 8→9, 9→10, 10→8, 10→5, 11→3. What is the…
- An undirected graph has vertices 0 to 13 and edges 0-1, 1-2, 2-0, 2-3, 3-4, 4-5, 5-3, 5-6, 6-7, 7-8, 8-6, 1-9, 9-10, 10-11, 11-9, 4-12…
- In how many different ways can the 10 distinct keys 1, 2, ..., 10 be arranged in the array positions 1 to 10 of a binary max-heap (each…
- How many binary search trees on the 7 keys 1 to 7 have height exactly 4 (height counted in edges, a single node has height 0)?