1 / 42

BTrees

BTrees. B-Tree Example (Order 2). 51. 11 30. 66 78. 2 7. 12 15 22. 35 41. 53 54 63. 68 69 71 76. 79 84 93. Find Example. 51. Find record with key 22. 11 30. 66 78. 2 7. 12 15 22. 35 41. 53 54 63. 68 69 71 76. 79 84 93. Find Example. 51. Find record with key 22. 11 30.

zarita
Download Presentation

BTrees

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. BTrees

  2. B-Tree Example (Order 2) 51 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 71 76 79 84 93

  3. Find Example 51 Find record with key 22 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 71 76 79 84 93

  4. Find Example 51 Find record with key 22 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 71 76 79 84 93 Find locates record here

  5. Insert Example #1 51 Insert record with key 57 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 71 76 79 84 93

  6. Insert Example #1 51 Insert record with key 57 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 71 76 79 84 93 Find locates record here

  7. Insert Example #1 51 Insert record with key 57 11 30 66 78 2 7 12 15 22 35 41 53 54 57 63 68 69 71 76 79 84 93 Insert record into leaf node

  8. Insert Example #2 51 Insert record with key 72 11 30 66 78 2 7 12 15 22 35 41 53 54 57 63 68 69 71 76 79 84 93

  9. Insert Example #2 51 Insert record with key 72 11 30 66 78 2 7 12 15 22 35 41 53 54 57 63 68 69 71 76 79 84 93 Find locates record here

  10. Insert Example #2 51 Insert record with key 72 11 30 66 78 53 54 57 63 68 69 71 76 2 7 12 15 22 35 41 79 84 93 Create a new node

  11. Insert Example #2 51 Insert record with key 72 11 30 66 78 53 54 57 63 68 69 71 72 76 2 7 12 15 22 35 41 79 84 93 Put record into its proper place among the records in leaf node.

  12. Insert Example #2 51 Insert record with key 72 11 30 66 71 78 53 54 57 63 68 69 72 76 2 7 12 15 22 35 41 79 84 93 SPLIT leaf node: - 1st d records stay in node - middle record to parent node - last d records to new node

  13. Insert Example #2 51 Insert record with key 72 11 30 66 71 78 Repeat if no room in parent node. 53 54 57 63 68 69 72 76 2 7 12 15 22 35 41 79 84 93

  14. Insert Example #3 51 Insert record with key 55 11 30 66 71 78 53 54 57 63 68 69 72 76 2 7 12 15 22 35 41 79 84 93 Find locates record here

  15. Insert Example #3 51 Insert record with key 55 11 30 66 71 78 53 54 57 63 68 69 2 7 12 15 22 35 41 72 76 79 84 93 Create a new node

  16. Insert Example #3 51 Insert record with key 55 11 30 66 71 78 53 54 55 57 63 68 69 2 7 12 15 22 35 41 72 76 Put record into its proper place among the records in leaf node. 79 84 93

  17. Insert Example #3 51 Insert record with key 55 11 30 55 66 71 78 5354 5763 68 69 2 7 12 15 22 35 41 72 76 SPLIT leaf node: - 1st d records stay in node - middle record to parent node - last d records to new node 79 84 93

  18. Delete Example #1 51 Delete record with key 71 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 71 76 79 84 93

  19. Delete Example #1 51 Delete record with key 71 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 71 76 79 84 93 Find locates record here

  20. Delete Example #1 51 Delete record with key 71 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 76 79 84 93 Remove record from leaf

  21. Delete Example #2 51 Delete record with key 78 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 76 79 84 93

  22. Delete Example #2 51 Delete record with key 78 11 30 66 78 Find locates record here 2 7 12 15 22 35 41 53 54 63 68 69 76 79 84 93

  23. Delete Example #2 51 Delete record with key 78 11 30 66 78 2 7 12 15 22 35 41 53 54 63 68 69 76 79 84 93 Locate next highest record (always in a leaf node).

  24. Delete Example #2 51 Delete record with key 78 11 30 66 79 OVERWRITE delete record with leaf node record. 2 7 12 15 22 35 41 53 54 63 68 69 76 79 84 93

  25. Delete Example #2 51 Delete record with key 78 11 30 66 79 2 7 12 15 22 35 41 53 54 63 68 69 76 79 84 93 Remove record from leaf.

  26. Delete Example #2 51 Delete record with key 78 11 30 66 79 2 7 12 15 22 35 41 53 54 63 68 69 76 84 93

  27. Delete Example #3 51 Delete record with key 35 11 30 66 79 2 7 12 15 22 35 41 53 54 63 68 69 76 84 93

  28. Delete Example #3 51 Delete record with key 35 11 30 66 79 2 7 12 15 22 35 41 53 54 63 68 69 76 84 93 Find locates record here

  29. Delete Example #3 51 Delete record with key 35 11 30 66 79 2 7 12 15 22 41 53 54 63 68 69 76 84 93 Remove record from leaf. Tree is now UNBALANCED!

  30. Delete Example #3 51 Delete record with key 35 11 30 66 79 2 7 12 15 22 41 53 54 63 68 69 76 84 93 If neighbor has at least d+1 records, redistribute records between: neighbor, parent, and find node.

  31. Delete Example #3 51 Delete record with key 35 11 22 66 79 2 7 12 15 30 41 53 54 63 68 69 76 84 93 Tree is now balanced.

  32. Delete Example #4 51 Delete record with key 7 11 22 66 79 2 7 12 15 30 41 53 54 63 68 69 76 84 93

  33. Delete Example #4 51 Delete record with key 7 11 22 66 79 2 7 12 15 30 41 53 54 63 68 69 76 84 93 Find locates record here

  34. Delete Example #4 51 Delete record with key 7 11 22 66 79 2 12 15 30 41 53 54 63 68 69 76 84 93 Remove record from leaf. Tree is now UNBALANCED!

  35. Delete Example #4 51 Delete record with key 7 11 22 66 79 2 12 15 30 41 53 54 63 68 69 76 84 93 Neighbors are too small (< d+1 records). Combine delete node, parent record, neighbor into single node.

  36. Delete Example #4 51 Tree is UNBALANCED! Repeat balancing. Delete record with key 7 22 66 79 2 11 12 15 30 41 53 54 63 68 69 76 84 93

  37. Delete Example #4 51 Neighbor has < (d+1) records. COMBINE self, parent, neighbor. Delete record with key 7 22 66 79 2 11 12 15 30 41 53 54 63 68 69 76 84 93

  38. Delete Example #4 Children of root collapse into root node. Delete record with key 7 22 51 66 79 2 11 12 15 30 41 53 54 63 68 69 76 84 93

More Related