-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmp
25 lines (25 loc) · 873 Bytes
/
tmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
RB-DELETE-FIXUP(T, x)
while x!=T.root and x.color==BLACK
if x==x.p.left
w=x.p.right
if w.color==RED
w.color=BLACK //case 1
x.p.color=RED //case 1
LEFT-ROTATE(T, x.p) //case 1
w=x.p.right //case 1
if w.left.color==BLACK and w.right.color==BLACK
w.color=RED //case 2
x=x.p //case 2
else
if w.right.color==BLACK
w.left.color==BLACK //case 3
w.color=RED //case 3
RIGHT-ROTATE(T, w) //case 3
w=x.p.right //case 3
w.color=x.p.color //case 4
x.p.color=BLACK //case 4
w.right.color=BLACK //case 4
LEFT-ROTATE(T, x.p) //case 4
x=T.root //case 4
else (same as then clause with "right" and "left" exchanged)
x.color=BLACK