They are not unique.
A simple proof would be to make a trivial algorithmic change, for example, to verify that we can change the root color and provide a case where this is still valid, for example:
1-B / \ 0-R 2-R
add(3):
1-B / \ 0-B 2-B \ 3-R
But the new algorithm could easily get
1-R / \ 0-B 2-B \ 3-R
The root is a different color, but of course the trees are still valid RB trees.
This may seem a little trivial, but you can expand on the idea (if you need proof that is less trivial) to test more than just the root. You can check the O (1) level deeply to make a non-trivial but real change that would create two different algorithms with the same runtime.
For example, check that the first 10 lines are filled and black, and changing the odd lines with red will give additional permanent work (i.e. O (1)) and a new algorithm.
It should be noted that this is simply a proof of non-uniqueness, and not an estimate of the amount of non-uniqueness. That is, something trivial, as itβs enough to prove the point, but it leaves the door open for RB algorithms that differ in more fundamental ways.
davin
source share