Algoritmo de Inserção Raghu Ramakrishman (by Gustavo Tadao) Árvore B
Lista de valores Root 1 Folhas 1 2 Próxima Página Insert(root, 7, newchildentry)(is non-leaf)Find i such that Ki <= entry’s keyvalue < Ki+1Insert(Pi, 7, newchildentry )(is leaf)(has no space)Split LNewchildentry = & Set sibling poiters in L and L2Return (newchildentry = & )
Fim Root (has no space)Split NNewchildentry = & N is rootCreate new node with (pointer to N, ) Make the tree’s root-node pointer to the new node;return Root
Algoritmo de Remoção Raghu Ramakrishman
Delete(parentpointer,Pi,19, oldchildentry ) Lista de valores 24 (is non-leaf)Find i such that Ki <= entry’s keyvalue < Ki+1Delete(nodepointer, Pi,entry, oldchildentry)(is non-leaf)Find i such that Ki <= entry’s keyvalue < Ki+1Delete(nodepointer, Pi,entry, oldchildentry)(Is leaf)Has entries to spareRemove entryReturn
Delete(parentpointer,Pi,24, oldchildentry ) Lista de valores 24 Próximo (is non-leaf)Find i such that Ki <= entry’s keyvalue < Ki+1Delete(nodepointer, Pi,entry, oldchildentry)(is non-leaf)Find i such that Ki <= entry’s keyvalue < Ki+1Delete(nodepointer, Pi,entry, oldchildentry)(Is leaf)Doesn’t have entries to spare – Merge L and SOldchildentry = &
Lista de valores New Root Fim Move all entries from M to node on leftReturnRemove *Oldchildentry from NDoesn’t have entries to spare – Merge N and SPull spliting key from parent down into node on leftMove all entries from M to node on leftReturn