# How costly can red-black trees be?

• Helen Cameron
• Derick Wood
Algorithms And Complexity
Part of the Lecture Notes in Computer Science book series (LNCS, volume 497)

## Abstract

We show that the internal path length of a red-black tree of size N is bounded above by 2N(log N−log log N)+O(N) and that this is, asymptotically, tight. This result further affirms a conjecture that whenever trees of size N, in a class of height-balanced binary trees, have height bounded from above by αlog2N, then the internal path length is bounded from above by α(log2N−log2 log2N)+O(N). We also prove that the asymptotic bound is tight for red-black trees. For this purpose, we introduce a class of red-black trees, the C(k, h) trees, which achieve the bound when k=h−2logh+ε, where |ε|≤1/2. This result solves the open problem of how bad red-black trees can be. In order to establish this result, we also prove that any red-black tree of a given height can be produced from a “skinniest” red-black tree of the same height by a series of simple insertions.

## References

1. [Bay72]
R. Bayer. Symmetric binary B-trees: Data structure and maintenance algorithms. Acta Informatica, 1(4):290–306, 1972.
2. [CW89]
Helen Cameron and Derick Wood. The internal path length of red-black trees. Research Report CS-89-50, University of Waterloo, 1989.Google Scholar
3. [GS78]
L.J. Guibas and R. Sedgewick. A dichromatic framework for balanced trees. In Proceedings of the 19th Annual IEEE Symposium on Foundations of Computer Science, pages 8–21, 1978.Google Scholar
4. [Knu73]
Donald E. Knuth. The Art of Computer Programming, Vol. 1: Fundamental Algorithms. Addison-Wesley, Reading, MA, 1973.Google Scholar
5. [KW90]
Rolf Klein and Derick Wood. A tight upper bound for the path length of AVL trees. Theoretical Computer Science, 72:251–264, 1990.
6. [MPRS79]
Raymond E. Miller, Nicholas Pippenger, Arnold L. Rosenberg, and Lawrence Snyder. Optimal 2–3-trees. SIAM Journal on Computing, 8(1):42–59, 1979.
7. [Oli82]
H.J. Olivié. A new class of balanced search trees: Half-balanced binary search trees. RAIRO Informatique Théorique, 16:51–71, 1982.Google Scholar
8. [OW82]
Th. Ottmann and D. Wood. A comparison of iterative and defined classes of search trees. International Journal of Computer and Information Sciences, 11(3):155–178, June 1982.
9. [Tar83]
Robert Endre Tarjan. Updating a balanced search tree in O(1) rotations. Information Processing Letters, 16:253–257, 1983.