We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
= Design and Analysis of Algorithms =
_=
14, 20
10,11, 12 ~_— [24.25.26]
Insert 19
Insert 13
10, 14, 20)
8] [112,43] [77, =
Deleting a Key from a B-tree
15.6.4,
Similar to insertion, with the addition of a couple of special cases,
Key can be deleted from any node.
More complicated procedure, but similar Performance figures: O(h) disk access
Olth) = O log, n) CPU time.
Deleting is done in a single pass down the tree, but needs to return to the node with
deleted key if it is an internal node,
In the latter case, the key is first moved down to a leaf. Final deletion always 3
place on a leaf. ,
The various cases of deletin,
* Considering
ig keys from a B-tree are as follows:
3 distinct cases for deletion,
* Leth be the key to by
Case 1; Mf key (h) ig in
are
¢ deleted, x the node containing the key k. Then the case
For example: |
node x and x is a leaf, then simply delete & from *- vent
“tus taken the initial tree with minimum degree t = 38 €
Scanned with CamScanner= B-Tree =
A re@ ee) 2
pekte'I8': Here, Key (k) = 18, x—> [11, 12, 18 | Delete (13)
Scanned with CamScanner2 SS
nalysis Sm
ign and Analysis of Algorithm:
= Desi
10, 14, @)
| J \N
ay 2122 |
89] Laas] Ge
[225.26] L 28257) La)
0] | Delete (20)
Here Key (k) = 20, x
(After Deletion Key (k) = 20)
(6) If the tight child of key (2)
Teplace key (x),
has atleast t keys, then its Smallest key moved upto
For &xample: Let US consider 4
he initial tree with minimum de,
Breet = 3.
Peleteng, Bere Key gy
14x, Delete (19)
ner
Scanned with CamScaniF qpild nor right child of key (&) has t keys then merge both childs and
ci
er ey (#-
et” wey le: set us consider the initial tree with minimum degree t = 3.
ple
for e
21,22 | [20.25.28 | 28,29 31.33 |
Delete (14)
peete'14': Here, Key (k) = 14,x7 1
89 [. 12, 17,18
14)
[After Deletion Key (1) =
Case 3;
i 3: If node x has (¢ — 1) keys-
cap has an i sate sibling wi ive an extra ke:
Sing an immediate sibling with at least t keys. Then give an e Es “ht
Bigg «Mey from x’s parent and a key move an appropriate from.’s immediate left a rie!
pi
‘rene ¥’s parent then delete the key (#)-
mls Mansa ans minimum degree = 5:
xy to node x by
y
ieial tree with
Scanned with CamScanner= Design and Analysis of Algorithms m
Here Koy (k) = 17,x-> [16,
15, 20
12,13 16, 17, G8) CO] 21.23
Delete (17)
(After Deletion Key (k) = 17)
(6) Ifx and both ofx’s immediate «11: : ia
valves saraed hofe S immediate siblings have t — 1 keys, mergex with one sped
* e
‘ey from 2’s parent down into the new merged node to become t
key for that node then delete the key (k),
For example: jl .
le: Consider the initial tree with minimum degree ¢ = 3-
Scanned with CamScanner[ 20,21 23,@) 28, 29
24,x—> [23,24
Delete 24: Here Key (k) =
Delete (24)
[after Deletion Key (= 241
N80
“SOLVED EXAMPLES Jttd Cuan”, MB
ie mee, FS OKS "eco 7 ration
Lf 18.2, Hann ena naonstee af inserting the ROT only. Draw oan roe
Scanned with CamScanner