Pages

Search Tutorials

Monday, 13 July 2015

A red–black tree is a special type of binary tree, used in computer science to organize pieces of comparable data, such as text fragments or numbers.
In addition to the requirements imposed on a binary search tree the following must be satisfied by a red–black tree:

1. A node is either red or black.

2. The root is black. (This rule is sometimes omitted. Since the root can always be changed from red to black, but not necessarily vice versa, this rule has little effect on analysis).

3. All leaves (NIL) are black. All leaves are of the same color as the root.

4. Every red node must have two black child nodes, and therefore it must have a black parent.

5. Every path from a given node to any of its descendant NIL nodes contains the same number of black nodes.