Presentation is loading. Please wait.

Presentation is loading. Please wait.

Red-Black Trees (Bayer, Guibas and Sedgewick) RBT example: 26 3 38 712 30 15 10 161923 35 39 28 14 21 20 47 41 17.

Similar presentations


Presentation on theme: "Red-Black Trees (Bayer, Guibas and Sedgewick) RBT example: 26 3 38 712 30 15 10 161923 35 39 28 14 21 20 47 41 17."— Presentation transcript:

1 Red-Black Trees (Bayer, Guibas and Sedgewick) RBT example:

2 Red-Black Trees (Bayer, Guibas and Sedgewick) Black-heights: Black-height of tree = black-height of root (2)

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

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

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

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

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

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


Download ppt "Red-Black Trees (Bayer, Guibas and Sedgewick) RBT example: 26 3 38 712 30 15 10 161923 35 39 28 14 21 20 47 41 17."

Similar presentations


Ads by Google