-1

This question comes from an exercise of Algorithm 4. I paste it here as follows: 3.3.19 With 1 bit per node for color, we can represent 2-, 3-, and 4-nodes. How many bits per node would we need to represent 5-, 6-, 7-, and 8-nodes with a binary tree?

There are only two colors black and red for the color of each node, either red or black, then self-evidence, 1 bit of information per node is enough to whatever we would like to represent. Why does it ask how many bits per node?

Harveybegood
  • 43
  • 1
  • 4

1 Answers1

1

Because 1 bit is sufficient for RB trees which are merely another representation of 2-3-4 trees, the question is how many bits are needed for a different tree basis.

An 8-node would have three internal levels (remember the count is how many outgoing links the node has, not any count of internal nodes):

    4
 2   6
1 3 5 7

This would complete a full 8-node. It would be possible to represent this as a blue-red-black tree (which would take two bits per node, with one bit combination unused).

colors = log_2 tree-basis bits = ciel log_2 colors

So with a tree basis of 4 you need 2 colors and one bit, a basis of 8 you need 3 colors and 2 bits, a basis of 16 would take 4 colors but still only need 2 bits, 3 bits would be able to handle a basis up to 256 (8 colors).

SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23