A RB tree with n internal nodes has height at most ? 2*lg(n+1) .
Thus the dynamic set operations on RB trees are all ? O(lgn) .
Proof by induction.
Initial condition: if height(x) = 0, then x is a leaf whose subtree
contains at least
2bh(x) - 1 = 20 - 1 = 0 internal nodes.
Consider internal node x. Each child has black-height bh(x)
(if the child is Red) or bh(x)-1 (if the child is Black).
By the Inductive Hypothesis, the child has at least
Therefore the subtree rooted at x has at least
(2bh(x) - 1 - 1) +
(2bh(x) - 1 - 1) + 1 internal nodes, or
2bh(x) - 1 internal nodes.