GATE CS 2009 · Indexing (B-trees, B+ trees, Hash Indexing)

MCQ · 2 marks · Problem DBMS-INDX-0054

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 that can be stored in it. The B+ tree is initially empty.10, 3, 6, 8, 4, 2, 1When a leaf overflows, the two smallest keys stay in the left leaf, the largest key goes to a new right leaf, and the largest key of the left leaf is copied into the parent as the separator; a search key \(k\) goes to the left of a separator \(s\) when \(k \le s\).The number of times leaf nodes get split as a result of these insertions is
  1. A
    2
  2. B
    3
  3. C
    4
  4. D
    5

Solve it on GATE DA practice →More Storage & Indexing problems

Show the worked solution\[\boxed{\text{leaf overflow at 3 keys} \;\Rightarrow\; [k_1,k_2]\,|\,[k_3],\ \text{separator } k_2,\ \ k\le k_2 \text{ goes left}}\]Insert 10, 3: leaf \([3,10]\).Insert 6: \([3,6,10]\) overflows, split 1: \([3,6]\,|\,[10]\), separator 6.Insert 8: \(8>6\), goes right: \([8,10]\).Insert 4: \([3,4,6]\) overflows, split 2: \([3,4]\,|\,[6]\), separator 4.Insert 2: \([2,3,4]\) overflows, split 3: \([2,3]\,|\,[4]\), separator 3.Insert 1: \([1,2,3]\) overflows, split 4: \([1,2]\,|\,[3]\).Internal-node splits (order 3) do not change which leaf a key reaches, so there are 4 leaf splits. (With the other common convention, separator = smallest key of the right leaf and \(k < s\) goes left, 8 would join \([3,6]\) and the count would be 5; the stated convention, which matches the GATE 2009 key, gives 4.)Answer: C

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com