GATE Computer ScienceHardGATE CS

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 height 3 (the root is at height 0, the leaves at height 3). What is the difference between the maximum and the minimum number of keys such a tree can store?

  1. A. 1242
  2. B. 1269
  3. C. 1188
  4. D. 1240

Correct answer: A. 1242

Maximum: every node full with 5 keys and 6 children gives 6⁴ − 1 = 1295 keys. Minimum: root has 1 key and 2 children, and every other node has 2 keys and 3 children, so the nodes per level are 1, 2, 6, 18 and the keys are 1 + 2·(2 + 6 + 18) = 53 (= 2tʰ − 1). The difference is 1295 − 53 = 1242.

More Algorithms questions

Exams that ask this topic