0% found this document useful (0 votes)
65 views7 pages

Deletion in B Tree

The document explains the process of deleting nodes in a B-Tree, which is divided into two main cases: deletion at leaf nodes and deletion at internal nodes. For leaf nodes, the deletion process varies based on whether the node has the minimum number of keys, involving borrowing from siblings or merging. For internal nodes, the target key can be replaced by either its inorder predecessor or successor if the respective child nodes have sufficient keys.

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)
65 views7 pages

Deletion in B Tree

The document explains the process of deleting nodes in a B-Tree, which is divided into two main cases: deletion at leaf nodes and deletion at internal nodes. For leaf nodes, the deletion process varies based on whether the node has the minimum number of keys, involving borrowing from siblings or merging. For internal nodes, the target key can be replaced by either its inorder predecessor or successor if the respective child nodes have sufficient keys.

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/ 7

Deletion In B-Tree

The deletion of nodes in a B-Tree can be broadly classified into two vivid cases:

 deletion at leaf node.


 deletion at internal node.
Let us say the node to be deleted is called the target key. The target key can either be at the
leaf node or an internal node. Let us now consider the various cases that follow:

1. If the target key is at the leaf node:


If the target key is at the leaf node, we further study the given data to check if any of the
following cases exist:

 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.

2. If the target key is at the internal node:


If the target key is at an internal node, we further study the given data to check if any of the
following cases exist:

 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.

minimum keys = ⌈ m/2⌉ – 1 = 2; maximum keys = ⌈ m/2⌉ + 1 = 4;


Assuming we have order = 5;

minimum children = ⌈ m/2⌉ = 3 maximum children = m = 5

You might also like