GATE / CS ARCHIVE

GATE CSE 2001 / QUESTION 22(a)

Construct the B+ tree

Data Structures · B-Trees & Multiway Search Trees · Full GATE CSE 2001 paper

GATE 2001, Q22(a) Descriptive
Report issue

B-Trees & Multiway Search Trees

Question 22(a), GATE 2001: B+ tree fan-out 3; insert 80,50,10,70,30,100,90, and show snapshots after 10,30,90.
Question 22(a), GATE 2001: B+ tree fan-out 3; insert 80,50,10,70,30,100,90, and show snapshots after 10,30,90.
Tap to enlarge
Answer & solution

Answer: With left-heavy leaf splits: after 10 root[80]; after 30 root[70]; after 90 root[70] with internal children[50] and[80,100]. (no official key was published)

B+ tree fan-out 3, initially empty; insert 80,50,10,70,30,100,90. Use at most 3 child pointers (2 separators) per internal node and at most 2 records per leaf. Non-root internal nodes need ≥2 children; non-root leaves need ≥1 record. Policy: split an overflowing 3-record leaf as 2 records on the left and 1 on the right; copy the minimum key of the right leaf upward. Split an overflowing internal node with 4 children into two groups of 2 children, promoting the middle separator. Internal separators equal the minimum key of their right subtree. Leaf links run left-to-right.

After inserting 10:
        [80]
       /    \
 [10,50] -> [80]

Insert 70: leaves become [10,50],[70],[80], root [70,80]. Inserting 30 splits the first leaf into [10,30] and [50], overflows the root to four children, and creates a new root:

            [70]
          /      \
       [50]      [80]
      /   \     /   \
 [10,30] [50] [70] [80]

Insert 100 into the last leaf. Insert 90 there, split [80,90,100] into [80,90] and [100], and add separator 100 to its parent. Final tree after 90:

             [70]
          /        \
       [50]       [80,100]
      /   \      /   |    \
 [10,30] [50]  [70] [80,90] [100]

Accessible description: root separator 70; left internal separator 50 points to leaves [10,30] and [50]; right internal separators 80,100 point to [70],[80,90],[100]. All leaves have equal depth and are linked in the displayed order. Other consistently applied split policies can yield different valid trees; this is one fully specified construction.

Original paper, page 10