lecture10

# lecture10 - Introduction to Algorithms...

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

Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 10 Prof. Erik Demaine

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

View Full Document
Introduction to Algorithms Day 18 L10.2 © 2001 by Charles E. Leiserson Balanced search trees Balanced search tree: A search-tree data structure for which a height of O (lg n ) is guaranteed when implementing a dynamic set of n items. Examples: AVL trees 2-3 trees 2-3-4 trees B-trees Red-black trees
Introduction to Algorithms Day 18 L10.3 © 2001 by Charles E. Leiserson Red-black trees This data structure requires an extra one- bit color field in each node. Red-black properties: 1. Every node is either red or black. 2. The root and leaves ( NIL ’s) are black. 3. If a node is red, then its parent is black. 4. All simple paths from any node x to a descendant leaf have the same number of black nodes = black-height( x ) .

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

View Full Document
Introduction to Algorithms Day 18 L10.4 © 2001 by Charles E. Leiserson Example of a red-black tree h = 4 8 8 11 11 10 10 18 18 26 26 22 22 3 3 7 7 NIL NIL NIL NIL NIL NIL NIL NIL NIL
Introduction to Algorithms Day 18 L10.5 © 2001 by Charles E. Leiserson Example of a red-black tree 8 8 11 11 10 10 18 18 26 26 22 22 3 3 7 7 NIL NIL NIL NIL NIL NIL NIL NIL NIL 1. Every node is either red or black.

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

View Full Document
Introduction to Algorithms Day 18 L10.6 © 2001 by Charles E. Leiserson Example of a red-black tree 8 8 11 11 10 10 18 18 26 26 22 22 3 3 7 7 NIL NIL NIL NIL NIL NIL NIL NIL NIL 2. The root and leaves ( NIL ’s) are black.
Introduction to Algorithms Day 18 L10.7 © 2001 by Charles E. Leiserson Example of a red-black tree 8 8 11 11 10 10 18 18 26 26 22 22 3 3 7 7 NIL NIL NIL NIL NIL NIL NIL NIL NIL 3. If a node is red, then its parent is black.

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

View Full Document
Day 18 L10.8 © 2001 by Charles E. Leiserson Example of a red-black tree 4. All simple paths from any node x to a descendant leaf have the same number of black nodes = black-height ( x ) . 8
This is the end of the preview. Sign up to access the rest of the document.

### Page1 / 29

lecture10 - Introduction to Algorithms...

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

View Full Document
Ask a homework question - tutors are online