CS FundamentalsVery hardGATE CS (PYQ pattern)

A B+ tree has leaf nodes holding at most 3 keys. Keys are inserted in the order 50, 20, 80, 10, 30, 60, 90, 70, 40, 25, 35, 5, 65, 75, 95, 85, 45, 55 starting from an empty tree. When a leaf overflows (4 keys) it splits into two leaves of 2 keys each. How many leaf nodes exist after all insertions?

  1. A. 6
  2. B. 8
  3. C. 10
  4. D. 9

Correct answer: B. 8

Simulate each insertion into the correct leaf and split on overflow (2 + 2 keys); the final leaves are [[5, 10], [20, 25], [30, 35], [40, 45], [50, 55, 60], [65, 70, 75], [80, 85], [90, 95]], i.e. 8 leaves for 18 keys (average fill 2.25).

More DBMS and SQL questions

Exams that ask this topic