{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 14 - Algorithms RB-Trees Red-Black Trees II Data Structures...

This preview shows pages 1–4. Sign up to view the full content.

Algorithms – RB-Trees Red-Black Trees II Data Structures and Algorithms Andrei Bulatov

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Algorithms – RB-Trees 14-2 Red-Black Properties A binary search tree is a red-black tree if it satisfies the following red-black properties: 1. Every node is either red or black 2. The root is black 3. Every leaf (Nil) is black 4. If a node is red, then both its children are black 5. For each node, all paths from the node to descendant leaves contain the same number of black nodes
Algorithms – RB-Trees 14-3 RB-Deletion RB-Delete also first runs the regular Deletion algorithm, and then fixes violations of the RB properties RB-Delete(T,z) if left[z]=Nil[T] or right[z]=Nil[T] then set y:=z else set y:=Tree-Successor(z) if left[y] Nil[T] then set x:=left[y] else set x:=right[y] set parent[x]:=parent[y] if parent[y]=Nil[T] then set root[T]:=x else if y=left[parent[y]]:=x then left[parent[y]:=x else right[parent[y]]:=x if y z then do set key[z]:=key[y] copy y’s data into z if color[y]=BLACK then RB-Delete-FixUp(T,x) return y

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 9

14 - Algorithms RB-Trees Red-Black Trees II Data Structures...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online