CS FundamentalsVery hardProduct company interview · GATE level

A B+ tree holds 10,000 keys in its leaves. A leaf holds at most 20 and at least 10 keys; an internal node has at most 30 and at least 15 children; the root, when it is not a leaf, has at least 2 children. What are the minimum and the maximum possible number of levels (counting the root level and the leaf level)?

  1. A. Minimum 3, maximum 5
  2. B. Minimum 3, maximum 3
  3. C. Minimum 4, maximum 4
  4. D. Minimum 3, maximum 4

Correct answer: D. Minimum 3, maximum 4

Fewest levels: pack every node. 10,000/20 = 500 leaves, 500/30 → 17 internal nodes, and one root over those 17: 3 levels (two levels could hold only 30 x 20 = 600 keys). Most levels: fill every node as little as allowed. A tree with h levels needs at least 2 x 15^(h-2) x 10 keys: h = 4 needs 2 x 225 x 10 = 4,500, which 10,000 keys can supply (for example 1,000 leaves, 66 nodes, 4 nodes, root), but h = 5 needs 67,500. So between 3 and 4 levels.

More DBMS and SQL questions

Exams that ask this topic