How to tell whether a red-black tree can have X black nodes and Y red nodes or not
问题 I have an exam next week in algorithms, and was given questions to prepare for it. One of these questions has me stumped though. "Can we draw a red-black tree with 7 black nodes and 10 red nodes? why?" It sounds like it could be answered quickly, but I can't get my mind around it. The CRLS gives us the maximum height of a RB tree with n internal nodes: 2*lg(n+1). I think the problem could be solved using this lemma alone, but am not sure. Any tips? 回答1: Since this is exam preparation, I don't