|
From Wikipedia
|
Goal:
|
/* ========================================================================
DeleteInternal( x, rx, N ):
(rx = the right tree pointer of x)
Delete (searchKey x, x's rightTreePtr rx) from an internal node N
in the B+-tree where minKey < x ≤ maxKey
======================================================================== */
DeleteInternal( x, rx, N )
{
Delete x, rx from node N; // Deletion done... but node may underflow !!!
/* ====================================
Check for underflow condition...
==================================== */
if ( N has ≥ ⌈(n+1)/2⌉ pointers /* At least half full*/ )
{
return; // Done
}
else
{
/* ---------------------------------------------------------
N underflowed: fix the size of N with transfer or merge
--------------------------------------------------------- */
/* ========================================================
Always try transfer first !!!
(Merge is only possible if 2 nodes are half filled)
======================================================== */
if ( leftSibling(N) has ≥ ⌈(n+1)/2⌉ + 1 pointers )
{
1. transfer right subtree link into N as the first link
2. transfer last key from leftSibling(N) through parent into N as the first key;
|