feb16 - Illinois Institute of Technology Department of...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: Illinois Institute of Technology Department of Computer Science Lecture 8: February 16, 2009 CS 430 Introduction to Algorithms Spring Semester, 2009 1 Red-black trees As we saw in the previous lecture, binary search trees provide efficient average-time access, but without some way to guarantee a balanced tree, they behave poorly in the worst case. The idea behind a balanced tree is precisely that: to guarantee some sort of balance in the tree structure, in particular to guarantee logarithmic height. There are many sorts of balanced trees, including weight-balanced trees, height-balanced (AVL) trees, B-trees, and red-black trees. We examine the red-black trees in detail here. 1.1 Properties of red-black trees Every red-black tree satisfies five properties: Each node is either red or black. Every leaf is black. The root is black. No two red nodes are adjacent. That is, no red node has a red parent or a red child. Paths from the root to any leaf all pass through the same number of black nodes (the black-height of the tree). As well, we can insist that the root be black without altering the status of a tree: changing the root node from red to black will not violate any of the properties, though it increases the black-height by 1. 1.2 A similar structure: 2-3-4 trees Although the primary structure we are studying is red-black trees, they are in fact equivalent to (and were originally presented as) 2-3-4 trees. Each node in a 2-3-4 tree contains either one data object and two children, two data objects and three children, or three data objects and four children. The other important property of 2-3-4 trees is that all its leaves have the same depth....
View Full Document

Page1 / 5

feb16 - Illinois Institute of Technology Department of...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online