...

/

Discussion on Red-Black Trees

Discussion on Red-Black Trees

Discover more aspects regarding the red-black trees.

We'll cover the following...

Additional notes

Red-black trees were first introduced by Guibas and SedgewickL. Guibas and R. Sedgewick. A dichromatic framework for balanced trees. In 19th Annual Symposium on Foundations of Computer Science, Ann Arbor, Michigan, 16–18 October 1978, Proceedings, pages 8–21. IEEE Computer Society, 1978.. Despite their high implementation complexity they are found in some of the most commonly used libraries and applications. Most algorithms and data structures textbooks discuss some variant of red-black trees.

AnderssonA. Andersson. Balanced search trees made simple. In F. K. H. A. Dehne, J.-R. Sack, N. Santoro, and S. Whitesides, editors, Algorithms and Data Structures, Third Workshop, WADS ’93, Montre ́al, Canada, August 11–13, 1993, Proceedings, volume 709 of Lecture Notes in Computer Science, pages 60–71. Springer, 1993. describes a left-leaning version of balanced trees that is similar to red-black trees but has the additional constraint that any node has at most one red child. This implies that these trees simulate 2-3 trees rather than 2-4 trees. They are significantly simpler, though, than the RedBlackTree structure presented in this chapter.

SedgewickR. Sedgewick. Left-leaning red-black trees, September 2008. URL: http://www.cs.princeton.edu/ ̃rs/talks/LLRB/LLRB.pdf [cited 2011-07-21]. describes two versions of left-leaning red-black trees. These use recursion along with a simulation of top-down splitting and merging in 2-4 trees. The combination of these two techniques makes for particularly short and elegant code.

A related, and older, data structure is the AVL treeG. Adelson-Velskii and E. Landis. An algorithm for the organization of information. Soviet Mathematics Doklady, 3(1259-1262):4, 1962.. AVL trees are height-balanced: At each node u, the height of the subtree rooted at u.left and the subtree rooted at u.right differ by at most one. It follows immediately that, if F(h)F(h) is the minimum number of leaves in a tree of height hh, then F(h)F(h) obeys the Fibonacci recurrence

...