(a) Insert key = 32 n=3 100 30 3 5 11 30 31 32
(a) Insert key = 7 n=3 100 30 7 3 5 11 30 31 3 5 7
(c) Insert key = 160 n=3 100 160 120 150 180 180 150 156 179 180 200 160 179
(d) New root, insert 45 n=3 30 new root 10 20 30 40 1 2 3 10 12 20 25 32 40 40 45
Deletion from B+tree (a) Simple case - no example (b) Coalesce with neighbor (sibling) (c) Re-distribute keys (d) Cases (b) or (c) at non-leaf
(b) Coalesce with sibling Delete 50 n=4 10 40 100 40 10 20 30 40 50
(c) Redistribute keys Delete 50 n=4 10 40 100 35 10 20 30 35 40 50
n=4 (d) Non-leaf coalese Delete 37 new root 25 25 10 20 30 40 40 30 25 26 1 3 10 14 20 22 30 37 40 45
Example: h(k) is 4 bits; 2 keys/bucket 1 i = 0001 1 1 1001 1100 “slide” conventions: slide shows h(k), while actual directory has key+pointer
Example: h(k) is 4 bits; 2 keys/bucket New directory 2 00 01 10 11 i = 1 i = 0001 1 1 1001 1 1100 1010 1100 Insert 1010
Example continued 2 0000 0111 0001 i = 2 00 01 10 11 1 0001 0111 2 1001 1010 Insert: 0111 0000 2 1100
Example continued i = 3 2 0000 0001 i = 2 2 0111 1001 1010 2 1001 1010 110 111 3 i = 0000 2 i = 0001 2 00 01 10 11 0111 2 1001 1010 2 1001 1010 Insert: 1001 2 1100
Example b=4 bits, i =2, 2 keys/bucket 0101 can have overflow chains! insert 0101 Future growth buckets 0000 0101 1010 1111 00 01 10 11 m = 01 (max used block) If h(k)[i ] m, then look at bucket h(k)[i ] else, look at bucket h(k)[i ] - 2i -1 Rule
Example b=4 bits, i =2, 2 keys/bucket 0101 insert 0101 1111 0101 Future growth buckets 11 0000 1010 0101 10 1010 1111 00 01 10 11 m = 01 (max used block)
Example Continued: How to grow beyond this? 100 101 110 111 3 i = 2 0000 100 0101 101 0101 1010 1111 0101 00 01 10 11 . . . m = 11 (max used block)