GATE / CS ARCHIVE

GATE CSE 2001 / QUESTION 22(b)

Delete from the B+ tree

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

GATE 2001, Q22(b) Descriptive
Report issue

B-Trees & Multiway Search Trees

Question 22(b), GATE 2001: 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. Starting with the final tree of the preceding solution, delete 30 and then 10.
Question 22(b), GATE 2001: 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. Starting with the final tree of the preceding solution, delete 30 and then 10.
Question 22(b), GATE 2001: 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. Starting with the final tree of the preceding solution, delete 30 and then 10.
Tap to enlarge
Answer & solution

Answer: After 30: leaf [10,30] becomes [10]. After 10: root [80], left internal[70] with [50],[70], right internal[100] with [80,90],[100]. (no official key was published)

Use the exact insertion policy and final tree in part (a). Deletion policy: remove a record, repair an empty leaf by borrowing from an adjacent same-parent sibling if it has spare records; otherwise merge. Repair an underfull internal node by borrowing one child from an adjacent same-parent sibling with spare children; otherwise merge. Update separators to right-subtree minima throughout.

After deleting 30, [10,30] becomes [10]. One record meets the minimum, so no redistribution occurs:

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

After deleting 10, the leftmost leaf is empty. Its sibling [50] cannot lend because it has the minimum one record. Merge into [50], remove the obsolete separator 50, and the left internal node temporarily has only one child. Its right internal sibling has three children and can lend its first child [70]. Move that child to the left internal node; update the root separator from 70 to 80. The final tree is:

             [80]
          /        \
       [70]        [100]
      /   \       /    \
   [50]  [70]  [80,90] [100]

Accessible description: root 80 has left internal node 70 with leaf children [50],[70], and right internal node 100 with leaf children [80,90],[100]. The linked leaf sequence is [50]→[70]→[80,90]→[100]. All capacity, occupancy, ordering and equal-depth invariants hold. A different valid policy in part (a) needs its own consistent deletion trace.

Original paper, page 10