0% found this document useful (0 votes)
43 views6 pages

Deletion in B+tree

Deleting an element from a B+ tree involves searching for the key, removing it, and balancing the tree if necessary. The document outlines the rules for node capacity and the steps to follow based on whether the key is in a leaf or internal node, including cases of underflow and borrowing keys from siblings. It also describes scenarios where the height of the tree may change after deletion.

Uploaded by

manalipowar25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views6 pages

Deletion in B+tree

Deleting an element from a B+ tree involves searching for the key, removing it, and balancing the tree if necessary. The document outlines the rules for node capacity and the steps to follow based on whether the key is in a leaf or internal node, including cases of underflow and borrowing keys from siblings. It also describes scenarios where the height of the tree may change after deletion.

Uploaded by

manalipowar25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Deletion from a B+ Tree

1)Deleting an element on a B+ tree consists of three main events:


searching the node where the key to be deleted exists,
deleting the key and
balancing the tree if required.
Underflow is a situation when there is less number of keys in a node than the minimum
number of keys it should hold.

2) one must know these facts about a B+ tree of degree m.


A node can have a maximum of m children. (i.e. 3)

A node should have a minimum of ⌈m/2⌉ children. (i.e. 2)


A node can contain a maximum of m - 1 keys. (i.e. 2)

A node (except root node) should contain a minimum of ⌈m/2⌉ - 1 keys. (i.e. 1)

3)While deleting a key, we have to take care of the keys present in the internal nodes (i.e.
indexes) as well because the values are redundant in a B+ tree.

4) Search the key to be deleted then follow the following steps.

Case I:
The key to be deleted is present only at the leaf node not in the indexes (or internal
nodes).
There are two cases for it:

A) There is more than the minimum number of keys in the node.


Simply delete the key

Deleting 40 from B-tree


B) There is an exact minimum number of keys in the node.
Delete the key and borrow a key from the immediate sibling.
Add the median key of the sibling node to the parent.

Deleting 5 from B-tree


Case II: The key to be deleted is present in the internal nodes as well.

Then we have to remove them from the internal nodes as well.

There are the following cases for this situation.

A) If there is more than the minimum number of keys in the node, then
simply delete the key from the leaf node and
delete the key from the internal node as well.
Fill the empty space in the internal node with the inorder successor.

Deleting 45 from B-tree


B) If there are an exact minimum number of keys in the node, then
simply delete the key from the leaf node and
delete the key from the internal node as well and
borrow a key from its immediate sibling (through the parent).
Fill the empty space created in the index (internal node) with the borrowed key.

Deleting 35 from B-tree


C) This case is similar to Case II (1) but here, empty space is generated above the
immediate parent node.
After deleting the key, merge the empty space with its sibling.
Fill the empty space in the grandparent node with the inorder successor.

Deleting 25 from B-tree


Case III

In this case, the height of the tree gets shrinked. It is a little complicated.

Deleting 55 from the tree below leads to this condition.

It can be understood in the illustrations below.

Deleting 55 from B-tree

You might also like