1 / 8

Red-Black Trees (Bayer, Guibas and Sedgewick)

Red-Black Trees (Bayer, Guibas and Sedgewick). 26. RBT example:. 41. 17. 30. 47. 14. 21. 10. 28. 38. 16. 19. 23. 35. 39. 20. 7. 12. 15. 3. Red-Black Trees (Bayer, Guibas and Sedgewick). 2. 26. Black-heights:. 41. 1. 17. 2. 30. 47. 1. 0. 14. 1. 21. 1. 10. 28.

maude
Download Presentation

Red-Black Trees (Bayer, Guibas and Sedgewick)

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. Red-Black Trees(Bayer, Guibas and Sedgewick) 26 RBT example: 41 17 30 47 14 21 10 28 38 16 19 23 35 39 20 7 12 15 3

  2. Red-Black Trees(Bayer, Guibas and Sedgewick) 2 26 Black-heights: 41 1 17 2 30 47 1 0 14 1 21 1 10 28 38 1 0 0 16 19 23 0 0 0 35 39 0 0 20 0 7 12 15 0 0 0 Black-height of tree = black-height of root (2) 3 0

  3. RBT Violation Fixes Case 1: c c Color flip d b d b a a Color flip fixes or moves violation towards the root.

  4. RBT Violation Fixes Case 2: c c Color flip d b d b a a Color flip fixes or moves violation towards the root.

  5. RBT Violation Fixes Case 3: c c Left Rotation d d b a Rest of Tree b a Rest of Tree Rest of Tree Rest of Tree Rest of Tree Rest of Tree Converted to Case 4

  6. RBT Violation Fixes Case 4: c b Right Rotation d b c a a d Rest of Tree Rest of Tree Rest of Tree Rest of Tree Rest of Tree Rest of Tree Now re-color Nodes b and c.

  7. RBT Violation Fixes Case 4: b b Color flip c c a a Rest of Tree d d Rest of Tree Rest of Tree Rest of Tree Rest of Tree Rest of Tree RBT violation is removed (see next slide).

  8. RBT Violation Fixes Case 4: c b d b c a Rest of Tree Rest of Tree Rest of Tree a d Rest of Tree Rest of Tree Rest of Tree RBT structure is restored.

More Related