You are on page 1of 7

Árvore B

Algoritmo de Inserção

Raghu Ramakrishman
(by Gustavo Tadao)
Lista de valores Root

7
1 10 20 30 40

Folhas 2
1 3 8 9 13 15 17191 21 24 25 28 32 35 37 39 40 43 46 47

1 3 7 8 9

Find iInsert(Pi,
such
Return
Set
Insert(root,
Newchildentry
that
sibling
(newchildentry
7,
(has
Ki
(is
newchildentry<NULL>)
<=
poiters
(is
Split
non-leaf)
7,
noentry’s
leaf)
newchildentry)
space)
L in
= &<7>
Lkeyvalue
=and
&<7>)
L2 < Ki+1

Próxima Página
Root

20
Root

10
7 20
10 30 40 20
30 30
40 40

1 3 7 8 9 13 15 17 19 21 24 25 28 32 35 37 39 40 43 46 47

Make
Create
the tree’s
new
Newchildentry
root-node
node
(hasNSplit
with
return
no
is root
space)
pointer
(pointer
N= &<20>totothe
N, new
<20>)
node;

Fim
Algoritmo de Remoção

Raghu Ramakrishman
Lista de valores

19
24 17

5 13 27 30

2 3 5 7 8 14 16 22 24 24
19 27 29 33 34 38 39

Delete(parentpointer<NULL>,Pi,19,
Find
Delete(nodepointer,
i such that
HasRemove
Ki
(is
entries
<=
(Is
Return
non-leaf)
Pi,entry,
entry’s
leaf)
to
entry
spare
keyvalue
oldchildentry<NULL>)
oldchildentry)
< Ki+1
Lista de valores

19
24 17

5 13 27 30

2 3 5 7 8 14 16 22 24 27 29 33 34 38 39

Delete(parentpointer<NULL>,Pi,24,
Doesn’t
Find
Delete(nodepointer,
i such
haveOldchildentry
that
entries
Ki
(is<=
(Is
non-leaf)
toPi,entry,
entry’s
leaf)
spare
= &<27>
keyvalue
–oldchildentry<NULL>)
oldchildentry)
Merge L<and
Ki+1S

Próximo
Lista de valores

19
24 17

New Root

5 13 17 30 27
30 30

2 3 5 7 8 14 16 22 27 29 27 29 33 34 38 39

Pull
Doesn’t
spliting
Move have
Remove
key
all entries
entries
from
*Oldchildentry
parent
Return
from
to spare
Mdown
to–node
Merge
from
into on
node
N Nleft
and
on S
left

Fim

You might also like