How costly can red-black trees be?
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.
Unable to display preview. Download preview PDF.
- [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
- [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
- [Knu73]Donald E. Knuth. The Art of Computer Programming, Vol. 1: Fundamental Algorithms. Addison-Wesley, Reading, MA, 1973.Google Scholar
- [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