Download presentation
Presentation is loading. Please wait.
1
G64ADS Advanced Data Structures
Red-Black Tree 1
2
Red Black Trees Binary search tree Each node is colored red or black.
The root is black If a node is red, its children must be black Every path from a node to a NULL reference must contain the same number of black nodes Every red node has a black parent.
3
Height = 5
4
Height = 5
5
Height = 5
6
Height = 5
7
Height = 5
8
Height = 5
9
Example Red-Black Tree
Height = 5
10
Rotations Zig rotation an Zig-Zag rotation work if S is black
Height = 5 Zig rotation an Zig-Zag rotation work if S is black
11
Rotations Height = 5 Color flip: Only if X’s parent is red do we continue with a rotation
12
Insertion Height = 5
13
Insertion Height = 5
14
Insertion Height = 5
15
Insertion Height = 5
16
Insertion Height = 5
17
Insertion Insert 45 Height = 5
18
Deletion Height = 5
19
Height = 5
20
Height = 5
21
Height = 5
22
Height = 5
23
Height = 5
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.