r/AskComputerScience • u/likejudo • Nov 29 '24
Red-Black Trees. Why can't a 3-node tree fulfill the conditions for RBT?
Challenge from instructor in Coursera Algorithms course.
see screenshot: https://imgur.com/a/4SKpX5y
If I color node #2 red, then it appears to me that all 3 conditions are met.
- root and leaves are Black
- Every Red node has two Black children.
- The Black height from any node is well defined and consistent.
I don't know what I am missing.
(in comparison, here is a different slide from his lecture with a RBT https://imgur.com/a/eUJW3S2)