2

I got an exercise about a variation of RB trees but I am struggling to see how to solve it, therefore I'll be happy to hear your opinion about it.
The exercise is:

Let us define a binary search tree which we will call Red-Red-Black tree if it satisfies the following:

  1. Every node is either red or black.
  2. Every leaf (NIL) is black.
  3. If a node is red, and its parent is red as well then both its children are black.
  4. For each node, all paths from the node to descendant leaves contain the same number of black nodes.

Find the largest possible number of internal nodes in Red-Red-Black tree with N nodes, such that their black height is $k$ find also what is the smallest possible number.

I was trying to think what I can deduce about the possible height of a node when I know its black height $k$.
So because of property number 3, we know that after each black node in the path we can have at most 2 consecutive red nodes, so I was wondering if I can say that the biggest possible height of a node that has a black height of $k$ is at most $3k$ and then try to figure out the cases about the possible level in the tree of nodes that has black height $k$ (Another observation which I am not sure about is: when we have a node which is not the root and this node has a black-height of $k$ then the siblings of this node must have the same black-height).
I will appreciate any clues. Thanks

Yarin
  • 285
  • 1
  • 8

0 Answers0