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?
- A. 1242
- B. 1269
- C. 1188
- 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
- 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)?
- How many times is x++ executed by the following code? for (i = 1; i <= 100; i++) for (j = 1; j <= 100; j += i) x++;