RedBlackTrees

# RedBlackTrees - Red-Black Trees 8:55 AM Outline and Reading...

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

4/1/2003 8:55 AM Red-Black Trees 1 Red-Black Trees 6 3 8 4 v z 4/1/2003 8:55 AM Red-Black Trees 2 Outline and Reading From (2,4) trees to red-black trees (§9.5) Red-black tree (§9.5) ± Definition ± Height ± Insertion ² restructuring ² recoloring ± Deletion ² restructuring ² recoloring ² adjustment 4/1/2003 8:55 AM Red-Black Trees 3 From (2,4) to Red-Black Trees A red-black tree is a representation of a (2,4) tree by means of a binary tree whose nodes are colored red or black In comparison with its associated (2,4) tree, a red-black tree has ± same logarithmic time performance ± simpler implementation with a single node type 2 6 7 3 5 4 4 6 2 7 5 3 3 5 OR 4/1/2003 8:55 AM Red-Black Trees 4 Red-Black Tree A red-black tree can also be defined as a binary search tree that satisfies the following properties: ± Root Property : the root is black ± External Property : every leaf is black ± Internal Property : the children of a red node are black ± Depth Property : all the leaves have the same black depth 9 15 4 6 2 12 7 21 4/1/2003 8:55 AM Red-Black Trees 5 Height of a Red-Black Tree Theorem: A red-black tree storing n items has height O (log n ) Proof: ± The height of a red-black tree is at most twice the height of its associated (2,4) tree, which is O (log n ) The search algorithm for a binary search tree is the same as that for a binary search tree By the above theorem, searching in a red-black tree

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 / 3

RedBlackTrees - Red-Black Trees 8:55 AM Outline and Reading...

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

View Full Document
Ask a homework question - tutors are online