b tree &
TRANSCRIPT
![Page 1: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/1.jpg)
B TREE &BASIC OPERATIONDESIGN & ANALSIS ALGORITHMS
Group #4
![Page 2: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/2.jpg)
DELETION IN BTREE
0Deletion is similar to insertion in Btree 0Key can be deleted from any node.0Therefore, you must ensure that before/after deletion,
the B-Tree maintains its properties
0Tip: after deletion root node must have one data value
![Page 3: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/3.jpg)
DELETION IN BTREE
0Case#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 I E F A B C
![Page 4: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/4.jpg)
DELETION IN BTREE
After Deletion Tip: In this case you
can directly delete node in
leaf
D G
E F H I A C
![Page 5: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/5.jpg)
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
![Page 6: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/6.jpg)
DELETION IN BTREE
G H K L O P R
J M DELET “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
![Page 7: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/7.jpg)
DELETION IN BTREE
J M O
G H K L P R
DELET “L”
![Page 8: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/8.jpg)
DELETION IN BTREE
G H K L M P R
J O
![Page 9: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/9.jpg)
DELETION IN BTREE
G H K M P R
J O
![Page 10: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/10.jpg)
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
![Page 11: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/11.jpg)
DELETION IN BTREE
Q
O P R S T W X
DELET “S”
![Page 12: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/12.jpg)
DELETION IN BTREE
Q
O P R S T W X
DELET “L”
![Page 13: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/13.jpg)
DELETION IN BTREE
Q
O P R T W X
DELET “S ”
![Page 14: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/14.jpg)
DELETION IN BTREE
Q R
O P T W X
![Page 15: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/15.jpg)
DELETION IN BTREE
R
O P Q
T W X
![Page 16: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/16.jpg)
DELETION IN BTREE 0CASE #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
![Page 17: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/17.jpg)
DELETION IN BTREE
Q T U
O P R S W X
DELET “U”
![Page 18: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/18.jpg)
DELETION IN BTREE
Q T
O P R S W X
![Page 19: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/19.jpg)
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”
![Page 20: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/20.jpg)
DELETION IN BTREE
I J M
G M K L O P
DELET “I”
![Page 21: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/21.jpg)
DELETION IN BTREE
J M
G M K L O P
![Page 22: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/22.jpg)
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
![Page 23: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/23.jpg)
DELETION IN BTREE
0 R U X
P Q S T V W Y Z
DELET “U ”
![Page 24: B tree &](https://reader035.vdocument.in/reader035/viewer/2022062223/58ac5f661a28ab8e258b6901/html5/thumbnails/24.jpg)
DELETION IN BTREE
R X
P Q S T V W Y Z