The following key values are inserted into a B+ tree in which the order of the…
2009
The following key values are inserted into a B+ tree in which the order of the internal nodes is 3, and that of the leaf nodes is 2, in the sequence given below. The order of internal nodes is the maximum number of tree pointers in each node, and the order of leaf nodes is the maximum number of data items stored in them. The B+ tree is initially empty. 10, 3, 6, 8, 4, 2, 1. The maximum number of times leaf nodes would get split up as a result of these insertions is
- A.
2
- B.
3
- C.
4
- D.
5
Attempted by 129 students.
Show answer & explanation
Correct answer: C
Answer: 4
Reasoning: Leaf nodes can hold at most 2 keys, so any insertion that makes a leaf contain 3 keys causes a leaf split. Simulate the insertions in sequence:
Insert 10 → single leaf: [10] (no split)
Insert 3 → leaf becomes [3, 10] (no split)
Insert 6 → target leaf would be [3, 6, 10], which exceeds capacity → split into [3, 6] and [10]. (leaf splits = 1)
Insert 8 → goes into [10] → becomes [8, 10] (no split)
Insert 4 → goes into [3, 6] → becomes [3, 4, 6], overflows → split into [3, 4] and [6]. (leaf splits = 2)
Insert 2 → goes into [3, 4] → becomes [2, 3, 4], overflows → split into [2, 3] and [4]. (leaf splits = 3). Note: this insertion may cause an internal node to split, but internal splits are not counted here.
Insert 1 → goes into [2, 3] → becomes [1, 2, 3], overflows → split into [1, 2] and [3]. (leaf splits = 4)
Therefore the maximum number of times leaf nodes get split for this insertion sequence is 4.
A video solution is available for this question — log in and enroll to watch it.