Recently, I have been going through search trees and I encountered red-black trees, the point confusing me is, In r-b tree, the root node should be black thats fine, now how will I decide whether the incoming node assumes red or black color.
I have gone through the wiki article but have not found a solution for this. I might be wrong, but I would be happy if someone can guide me through the exact material.
[Edit] That is for example, if my keys are {7, 2, 4, 1, 9, 10, 8}
Here 7 is root and it assumes black color, but what color does 2 assume? How do we decide that? And how do we decide what color the other nodes assume?
7 - (Black)
2 9
1 4 8 10
NIL NIL NIL NIL NIL NIL NIL NIL
Do we have a random toss that decides the color of the node to be red or black. Or is it some other process.
Thank you.