- 2068 Magh · 5 marks
Resolving underflow in B-tree
Short answer
Underflow is resolved by balance (borrow a key from a sibling with more than minimum keys) or combine (merge sibling and parent separator into one node). Balance redistributes keys; combine may reduce tree height.
How can you resolve underflow problem in B-tree? Discuss with reference to balance and combine.
Underflow happens in a B-tree of order m when a deletion leaves a non-root node with fewer than the minimum number of keys, ⌈m/2⌉ − 1 (for order 5, fewer than 2 keys). The node is then repaired using an adjacent sibling that has the same parent.
1. Balance (borrow / redistribute / rotate)
Used when an adjacent sibling has more than the minimum number of keys.
- Move the separator key in the parent down into the underflowing node.
- Move the nearest key of the rich sibling up to replace the separator in the parent.
- If the nodes are internal, also move the child pointer that goes with the borrowed key.
Example (order 5, min 2 keys). Delete 10 from:
[30] [40]
/ \ delete 10 / \
[10 20] [40 50 60] ==> [20 30] [50 60]
After the deletion the left leaf is [20], with only 1 key (underflow). The right sibling has 3 keys, so 30 comes down and 40 goes up.
2. Combine (merge / concatenate)
Used when the sibling has exactly the minimum number of keys, so nothing can be borrowed.
- Merge the underflowing node, the separator key from the parent, and the sibling into one node.
- Remove the separator and the extra pointer from the parent.
- The parent may now underflow, so repeat balance or combine upward. If the root loses its last key, the merged node becomes the new root and the tree height decreases by one.
Example. Delete 10 from:
[30]
/ \ delete 10
[10 20] [40 50] ==> [20 30 40 50]
After the deletion [20] underflows, and its sibling [40 50] has only the minimum 2 keys. Combine [20] + 30 + [40 50] = [20 30 40 50]; the root becomes empty and is removed, so the merged node is the new root.
| Method | When | Effect on parent | Height |
|---|---|---|---|
| Balance | sibling has spare keys | one key replaced | unchanged |
| Combine | sibling at minimum | loses one key | may decrease |
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Queue overflow and underflow errors · Data Structure and Algorithm, chapter 2
- TOH algorithm and recursion tree · Data Structure and Algorithm, chapter 5 · asked 2×
- Tree recursion and TOH with n disks · Data Structure and Algorithm, chapter 5
- Box trace and TOH recursion tree · Data Structure and Algorithm, chapter 5
- AVL delete then insert gives same tree? · Data Structure and Algorithm, chapter 6
- Overfitting in ID3 and decision tree rules · Data Mining, chapter 3
- Reference argument in copy constructor · Object Oriented Programming, chapter 4
- Depreciation, causes; declining balance for 50,000 · Engineering Economics, chapter 7 · asked 2×
- Monthly deposits, quarterly compounding, balance at year 8 · Engineering Economics, chapter 2