10-Balanced-Search-Trees

# 10-Balanced-Search-Trees - Algorithms LECTURE 10 Balanced...

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

Algorithms L7.1 Professor Ashok Subramanian L ECTURE 10 Balanced Search Trees Red-black trees Height of a red-black tree Rotations Insertion Algorithms

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

View Full Document
Algorithms L7.2 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
Algorithms L7.3 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
Algorithms L7.4 Example of a red-black tree h = 4 8 11 10 18 26 22 3 7 NIL NIL NIL NIL NIL NIL NIL NIL NIL
Algorithms L7.5 Example of a red-black tree 8 11 10 18 26 22 3 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
Algorithms L7.6 Example of a red-black tree 8 11 10 18 26 22 3 7 NIL NIL NIL NIL NIL NIL NIL NIL NIL 1. The root and leaves ( NIL ’s) are black.
Algorithms L7.7 Example of a red-black tree 8 11 10 18 26 22 3 7 NIL NIL NIL NIL NIL NIL NIL NIL NIL 1. 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
L7.8 Example of a red-black tree 1. 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.

## This note was uploaded on 04/29/2011 for the course IT 201 taught by Professor K.v.arya during the Spring '11 term at IIT Kanpur.

### Page1 / 29

10-Balanced-Search-Trees - Algorithms LECTURE 10 Balanced...

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

View Full Document
Ask a homework question - tutors are online