Slideshow:
|
I will illustrate the "node split" procedure with 2 examples first
Then I will show you the algorithm
Example: we want to insert the key 40 (+ record pointer) into the full B+-tree node
|
Example: we want to insert the key 4 (+ record pointer) into the full B+-tree node
|
Allocate a new node R (the right node); /* ======================================== Link the leaf nodes ======================================== */ R.last pointer = L.last pointer L.last poinetr = R /* ============================================ Divide the key in half over the 2 nodes ============================================ */ Let: x = insertedKey; m = middle key in L (= k⌈(n+1)/2⌉); if ( x > m ) { /* ====================================== x belongs to the right half ====================================== */ for (key = "middle + 1" key; key < x; next key) Move key from L to R ; Put x in R; for ( current key ; last key ; next key ) Move key from L to R } else { /* ====================================== x belongs to the left half ====================================== */ for (key = "middle" key; last key; next key) Move key from L to R ; /* -------------------------- Make an empty space for x -------------------------- */ for (key = "middle − 1" key; key < x; previous key) Move the key 1 position to the right within L; Put x in the empty slot within L; } |
|
|