-1

One of the questions from my homework was to find exact lower bound of

(#black nodes)/(#red nodes)

in rb-tree. the bound must be not asymptotic. Any suggestions?

Your help would be very appreciated.

taypen
  • 13
  • 4

1 Answers1

3

Assuming this is a homework:

Let's review some properties of RedBlack Trees from Wikipedia:

  1. ...
  2. The root is black.
  3. All leaves are black.
  4. Both children of every red node are black.
  5. ...

To get a lower bound on #B/#R you want to construct a tree that has as many red nodes as possible. (Unfortunately, due to 2,3,4 you cannot construct an all red tree)

Some questions worth thinking about:

  • can you fit more red nodes in balanced or not-so-balanced trees?
  • does even or odd maximal height make a difference?
  • given that a tree contains 3, 7, ..., (2^n)-1 back nodes how many red ones can you fit in?
subsub
  • 1,857
  • 10
  • 21
  • Thanks for reply, yeah i looked on this properties but i still dont see the whole picture... – taypen Apr 12 '11 at 11:09
  • There was a consensus not to use the `[homework]` tag any more, along with other meta tags. – Konrad Rudolph Apr 12 '11 at 11:24
  • @Konrad-Rudolph, ah ok, I missed that. – subsub Apr 12 '11 at 11:36
  • Is the Correct answer is that bound equals 2? Because leafs are half of all the nodes in tree – taypen Apr 12 '11 at 11:52
  • @taypen: "Because leafs are half of all the nodes in tree", and only leafs are black, would mean that black and red can have the same count, right? so the ratio would be 1 in that case.... – subsub Apr 12 '11 at 13:57