Árvore B Algoritmo de Inserção Raghu Ramakrishman (by Gustavo Tadao) Lista de valores Root 7 10 1 Folhas 2 1 3 8 9 1 3 20 13 15 17191 30 40 21 24 25 28 32 35 37 39 40 43 46 47 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 1 3 7 8 9 20 10 13 15 17 19 30 40 21 24 25 28 20 30 30 40 32 35 37 39 40 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 2 3 5 13 7 27 8 14 16 22 24 24 19 30 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 2 3 5 13 7 27 8 14 16 22 24 30 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 2 3 5 13 7 17 8 30 14 16 27 30 22 27 29 30 27 29 33 34 38 39 Pull Doesn’t spliting Move have Remove key all entries entries from *Oldchildentry parent Return from to spare M down to–node Merge from into on node N Nleft and on S left Fim