CMPS340   File Processing
B-tree insertion/deletion examples

 

Consider the B-tree T of order 4 illustrated below. (Due to typesetting restrictions, the edges are missing and the nodes at the leaf level appear to be on two different levels.)

For each operation in the list (a) through (f), show the B-tree that results from performing that operation on T. (Each operation is to be applied to the tree T illustrated below, not to the tree resulting from applying all the previous operations to T.

Assume, in carrying out the operations, that redistribution is used whenever possible. That is, split an overflowing node only if all its adjacent siblings are full. Similarly, concatenate two nodes only if all adjacent siblings of the underflowing node are on the verge of underflowing.

(a) insert 23
(b) delete 12
(c) insert 14
(d) delete 63
(e) insert 41
(f) delete 96

                            +----+----+----+
                            | 24 | 63 | 95 |
                            +----+----+----+
                           /    /      \    \ 
              +-----------+    /        \    +---------------------+
             /                /          +------+                   \ 
            /                /                   \                   \
  +---+----+        +----+----+----+              +----+----+       +----+
  | 6 | 19 |        | 34 | 50 | 58 |              | 70 | 85 |       | 98 |
  +---+----+        +----+----+----+              +----+----+       +----+
  |   |    |        |    |     \    \             |    |    |       |    |
  |   |    |        |    |      \    +---+        |    |    |       |    |
  |   |    |        |    |       +----+   \       |    |    |       |    |
+---+ | +----+----+ |+----+----+----+ | +----+  +----+ | +----+  +----+ +----+
| 2 | | | 20 | 21 | || 39 | 44 | 48 | | | 61 |  | 67 | | | 88 |  | 96 | | 99 |
+---+ | +----+----+ |+----+----+----+ | +----+  +----+ | +----+  +----+ +----+
      |             |                 |                |
+---+----+----+  +----+----+----+  +----+----+----+  +----+----+
| 9 | 12 | 16 |  | 27 | 30 | 32 |  | 52 | 55 | 57 |  | 75 | 80 |
+---+----+----+  +----+----+----+  +----+----+----+  +----+----+