1 / 7

Algoritmo de Inserção

Árvore B. Algoritmo de Inserção. Raghu Ramakrishman (by Gustavo Tadao). Lista de valores. Root. 7. 1. 10. 20. 30. 40. 2. Folhas. 1. 3. 8. 9. 13. 15. 17. 191. 21. 24. 25. 28. 32. 35. 37. 39. 40. 43. 46. 47. 1. 3. 7. 8. 9.

ovid
Download Presentation

Algoritmo de Inserção

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Árvore B Algoritmo de Inserção Raghu Ramakrishman (by Gustavo Tadao)

  2. Lista de valores Root 7 1 10 20 30 40 2 Folhas 1 3 8 9 13 15 17 191 21 24 25 28 32 35 37 39 40 43 46 47 1 3 7 8 9 Newchildentry = &<7> Split L (is leaf) Set sibling poiters in L and L2 Insert(Pi, 7, newchildentry<NULL>) Find i such that Ki <= entry’s keyvalue < Ki+1 (is non-leaf) Insert(root, 7, newchildentry) (has no space) Return (newchildentry = &<7>) Próxima Página

  3. Root 20 Root 10 20 30 40 7 10 20 30 40 30 40 1 3 7 8 9 13 15 17 19 21 24 25 28 32 35 37 39 40 43 46 47 N is root Create new node with (pointer to N, <20>) Split N (has no space) Make the tree’s root-node pointer to the new node; return Newchildentry = &<20> Fim

  4. Algoritmo de Remoção Raghu Ramakrishman

  5. Lista de valores 19 17 24 5 13 27 30 2 3 5 7 8 14 16 22 19 24 24 24 27 29 33 34 38 39 Return Delete(nodepointer, Pi,entry, oldchildentry) Remove entry (is non-leaf) Find i such that Ki <= entry’s keyvalue < Ki+1 Find i such that Ki <= entry’s keyvalue < Ki+1 (is non-leaf) Delete(nodepointer, Pi,entry, oldchildentry) Has entries to spare Delete(parentpointer<NULL>,Pi,19, oldchildentry<NULL>) (Is leaf)

  6. Lista de valores 19 17 24 5 13 27 30 2 3 5 7 8 14 16 22 24 27 29 33 34 38 39 Delete(nodepointer, Pi,entry, oldchildentry) Doesn’t have entries to spare – Merge L and S (is non-leaf) Find i such that Ki <= entry’s keyvalue < Ki+1 Delete(nodepointer, Pi,entry, oldchildentry) (is non-leaf) Find i such that Ki <= entry’s keyvalue < Ki+1 (Is leaf) Delete(parentpointer<NULL>,Pi,24, oldchildentry<NULL>) Oldchildentry = &<27> Próximo

  7. Lista de valores 19 17 24 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 Move all entries from M to node on left Return Remove *Oldchildentry from N Doesn’t have entries to spare – Merge N and S Pull spliting key from parent down into node on left Move all entries from M to node on left Return Fim

More Related