Solution for 13.1-7 exercises of RB tree chapter in Introduction to Algorithms 3rd
Describe a red-black tree on n keys that realizes the largest possible ratio of red in-ternal nodes to black internal nodes. What is this ratio? What tree has the smallest possible ratio, and what is the ratio?
Solution:
1. Largest possible ration
Red node is as many as possible. h = [lg(k)].
Ration = (n-(2^(0)+2^(2)+...+2^(h/2)))/(2^(0)+2^(2)+...+2^(h/2);
2. Smallest possible ration
Black node is as many as possible.
Ration = (n-2^h)/2^h;