Introduction
With this set of notes we begin examining advanced tree structures with which
you may have had no experience.
For the most part the various trees that we
will examine are applied to the problem of searching, although data
representation is still an issue.
For each of the advanced tree structures that
we will cover, we’ll examine the basic structure of the tree and identify the
characteristics which distinguish it from other trees in addition to exploring the
normal operations of insertion, deletion, and update.
When appropriate we’ll
also focus on suitable applications for the various trees.
RedBlack Trees
A
redblack tree
is a binary search tree in which every node in the tree is
colored either red or black.
The remaining properties of a redblack tree are
derived from its corresponding extended binary tree.
A binary tree in which a special node called an
external node
replaces every
empty subtree is called an
extended binary tree
.
Figure 1 illustrates a binary
tree and its corresponding extended binary tree.
Figure 1 – (a) binary tree, (b) extended binary tree
RedBlack Trees 
1
Advanced Tree Structures – RedBlack Trees (5)
c
a
b
d
e
f
(a)
(b)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Based upon the definition of the extended binary tree, we can define the
additional properties of a redblack tree.
A redblack tree is defined as
1
:
1.
A binary search tree.
2.
The root and all external nodes are colored black.
3.
No roottoexternalnode path has two consecutive red nodes.
4.
All roottoexternalnode paths have the same number of black nodes.
Figure 2 illustrates an example redblack tree.
Figure 2 – A redblack tree
Notice in Figure 2 that the tree satisfies all of the properties of a redblack tree.
Namely, (1) it is a BST, (2) the root and all external nodes are colored black, (3)
no roottoexternalnode path has two consecutive red nodes, and (4) all rootto
externalnodes paths contain the same number of black nodes; two in this
example.
(Applying the alternate definition we have:
every path from the root to
an external node has exactly two black pointers and three black nodes
(including the root and the external node); and no such path has two
consecutive red pointers.)
The
rank
of a node in a redblack tree is the number of black pointers (or the
number of black nodes minus 1) on any path from the node to any external
1
An equivalent definition arises from assigning colors to the references (pointers) between a node and its children.
The
pointer from a parent to a black child is black and to a red child is red.
Additionally, (1) pointers from an internal node to
an external node are black, (2) no roottoexternalnode path has two consecutive red references, and (3) all rootto
externalpaths have the same number of black references.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Summer '09
 Computer Science, Redblack tree

Click to edit the document details