redblk5 - Advanced Tree Structures Red-Black Trees (5)...

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

View Full Document Right Arrow Icon
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. Red-Black Trees A red-black tree is a binary search tree in which every node in the tree is colored either red or black. The remaining properties of a red-black 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 Red-Black Trees - 1 Advanced Tree Structures – Red-Black Trees (5) c a b d e f (a) (b)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Based upon the definition of the extended binary tree, we can define the additional properties of a red-black tree. A red-black tree is defined as 1 : 1. A binary search tree. 2. The root and all external nodes are colored black. 3. No root-to-external-node path has two consecutive red nodes. 4. All root-to-external-node paths have the same number of black nodes. Figure 2 illustrates an example red-black tree. Figure 2 – A red-black tree Notice in Figure 2 that the tree satisfies all of the properties of a red-black tree. Namely, (1) it is a BST, (2) the root and all external nodes are colored black, (3) no root-to-external-node path has two consecutive red nodes, and (4) all root-to- external-nodes 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 red-black 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 root-to-external-node path has two consecutive red references, and (3) all root-to- external-paths have the same number of black references.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 25

redblk5 - Advanced Tree Structures Red-Black Trees (5)...

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

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