Deletion in B Tree
Deletion in B Tree
The deletion of nodes in a B-Tree can be broadly classified into two vivid cases:
Case 1: If the leaf node consists of the min number of keys according to the given
degree/order, then the key is simply deleted from the node.
Case 2: If the leaf node not contains the minimum number of keys, then:
o Case 2a: The node can borrow a key from the immediate left sibling node,
if it has more than the minimum number of keys. The transfer of the keys take
place through the parent node, i.e, the maximum key of the left sibling moves
upwards and replaces the parent; while the parent key moves down to the
target node from where the target key is simply deleted.
o Case 2b: The node can borrow a key from the immediate right sibling
node, if it has more than the minimum number of keys. The transfer of the
keys take place through the parent node, i.e, the minimum key of the right
sibling moves upwards and replaces the parent; while the parent key moves
down to the target node from where the target key is simply deleted.
o Case 2c: If neither of the siblings have keys more than the minimum
number of keys required then, merge the target node with either the left or
the right sibling along with the parent key of respective node.
Case 1: If the left child has more than the minimum number of keys, the target
key in the internal node is replaced by its inorder predecessor ,i.e, the largest
element of the left child node.
Case 2: If the right child has more than the minimum number of keys, the target
key in the internal node is replaced by its inorder successor ,i.e, the smallest
element of the right child node.
Example:
Let us consider the given tree. From the given tree we are to delete the following elements:
A = 20 , 53 , 89 , 90 , 85.