NIST

red-black tree

(data structure)

Definition: A nearly-balanced tree that uses an extra bit per node to maintain balance. No leaf is more than twice as far from the root as any other.

Formal Definition: A red-black tree with n internal nodes has height at most 2log2(n+1).

Also known as symmetric binary B-tree.

Generalization (I am a kind of ...)
B-tree.

Specialization (... is a kind of me.)
AVL tree.

Aggregate child (... is a part of or used in me.)
left rotation, right rotation.

See also height-balanced tree.

Note: The extra bit "colors" the node red or black, hence the name. These were called "symmetric binary B-trees" when first invented. The red/black naming and explanation was given by Guibas and Sedgewick.

An AVL tree is at least as balanced as a red-black tree.

Author: PEB

Implementation

analysis, explanation, examples, and code (C). Ben Pfaff's libavl (C) including pointers to other implementations.

More information

Rudolf Bayer, Symmetric Binary B-Trees: Data Structures and Maintenance Algorithms, Acta Informatica, 1:290-306, 1972.
Leo J. Guibas and Robert Sedgewick, A Dichromatic Framework for Balanced Trees, Proceedings of the 19th Annual Symposium on Foundations of Computer Science, pages 8-21. IEEE Computer Society, 1978.


Go to the Dictionary of Algorithms and Data Structures home page.

If you have suggestions, corrections, or comments, please get in touch with Paul Black.

Entry modified 12 November 2019.
HTML page formatted Tue Nov 12 10:04:35 2019.

Cite this as:
Paul E. Black, "red-black tree", in Dictionary of Algorithms and Data Structures [online], Paul E. Black, ed. 12 November 2019. (accessed TODAY) Available from: https://www.nist.gov/dads/HTML/redblack.html