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?
Since this is exam preparation, I don’t want to give you a direct answer, but I think what you need to consider is the properties that govern how you build a Red-Black Tree:
(Stole these from the wikipedia page: http://en.wikipedia.org/wiki/Red-black_tree)
Given the count of nodes you listed, can you meet all of these properties?