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

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

View Full Document Right Arrow Icon
Algorithms – RB-Trees Red-Black Trees II Data Structures and Algorithms Andrei Bulatov
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/19/2009 for the course CS CMPT 307 taught by Professor A.bulatov during the Fall '09 term at Simon Fraser.

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 Right Arrow Icon
Ask a homework question - tutors are online