GATE Computer ScienceVery hardGATE CSE · UGC NET

A B-tree of order 5 (each node holds at most 4 keys) is built by inserting 1, 2, 3, …, 60 in increasing order. When a node overflows to 5 keys, its middle (3rd) key moves up to the parent, leaving 2 keys in the left node and 2 in the new right node. How many nodes does the final tree contain (leaves and internal nodes together)?

  1. A. 31
  2. B. 26
  3. C. 35
  4. D. 29

Correct answer: D. 29

Sequential insertion leaves every split node with exactly 2 keys; counting the nodes created by all splits (height 4) gives 29 nodes.

More Programming and Data Structures (GATE) questions

Exams that ask this topic