2. DELETION IN BTREE
0 Deletion is similar to insertion in Btree
0 Key can be deleted from any node.
0 Therefore, you must ensure that before/after deletion,
the B-Tree maintains its properties
0 Tip: after deletion root node must have one data value
3. DELETION IN BTREE
0 Case#1:- if x is a leaf node and x has >= keys then just
delete the key from node-x
delete: “B”
keys =3=t
D G
H IE FA B C
4. DELETION IN BTREE
After Deletion Tip: In this case you
can directly delete
node in leaf
D G
E F H IA C
5. DELETION IN BTREE
CASE 2: the node x containing the target key is a leaf
and x has exactly (t-1) keys , i.e, the min of keys that x
should have then
(a) If x has a sibling with at least t keys , then move x’s
parent key into x and move the appropriate of form
x’s sibling into the open slot in parent nodes then
delete the target
6. DELETION IN BTREE
G H K L O P R
J MDELET “L”
That node x contain target , it has min no of key is 2 (as t=3)
sibling o f x
that has >=3
keys
10. DELETION IN BTREE
0 (b) If x’s siblings also have (t-1) keys merge x with
one of its sibling by bringing down the parent as the
median key , then delete the key
Q T
O P R S W X
DELET “S”
Node x contain the
key node of the
siblings of node x
have >=t keys all
have t-1=2 keys
16. DELETION IN BTREE
0 CASE #3 if the node x containing the target key is as the
internal node
0 (a) it the target key’s left child has at least t keys then its target
value can be moved to the parent to replace the target key
Q U
O R R S T W X
DELET “U ”
U has a subtree
root then t =3
keys
19. DELETION IN BTREE
0 (B) if the target keys right child has at least t key then
its smallest value can moved to the parent to replace
the target key
I M
G M J K L O P
DELET “I”
22. DELETION IN BTREE
(C) IF the node of the target keys children have at least t
keys then the children must be merged into one and
the key could be removed
R U X
P Q S T V W
DELETE “U ”
Y Z