Is this a Red-Black Tree?

161 Views Asked by At

I tried to build RBT (Red-Black Tree) via this way:
I build a balanced binary search tree (much as I can) and then colored it...

Now the Q is: if this is a legal RBT?
enter image description here

At my opinion is yes, because all the benefits of RBT are the tree:

  1. The root is black.
  2. There is two red vertices one after another.
  3. The Black-Height is as need to be at a RBT.

If I miss something and it's not a legal RBT I'll be glad if you will correct me and tell me why...

Thank you!

1

There are 1 best solutions below

0
On

It is a legal RBT but the point of the RBT is that the insert and delete operations are O(log n), in your approach this may not be true. Whether your approach is always colourable in this way - I am not sure.