Red-Black Trees (Bayer, Guibas and Sedgewick) - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Red-Black Trees (Bayer, Guibas and Sedgewick)

Description:

Red-Black Trees (Bayer, Guibas and Sedgewick) RBT example: 26. 3. 38. 7. 12. 30. 15. 10. 16 ... Color flip fixes or moves violation towards the root. RBT ... – PowerPoint PPT presentation

Number of Views:100
Avg rating:3.0/5.0
Slides: 9
Provided by: Prof150
Category:
Tags: bayer | black | guibas | red | sedgewick | trees

less

Transcript and Presenter's Notes

Title: Red-Black Trees (Bayer, Guibas and Sedgewick)


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

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

2
26
41
1
17
2
30
47
1
0
14
1
21
1
38
10
28
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
b
Rest of Tree
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.
Write a Comment
User Comments (0)
About PowerShow.com