- #1
Joseph1739
- 33
- 0
I don't understand the requirements for a red-black tree.
Using this photo:
https://upload.wikimedia.org/wikipedia/commons/6/66/Red-black_tree_example.svg
One of the 5 required properties is that all leaves are black.
A leaf is a node without a child, so that would only be 11 and 15 two links down from the root. So why is 1 and 25 black? They clearly have a child, so they are not leaves. Similarly, why is 6, 22, and 27 not black. They don't have children so they should be black.
Using this photo:
https://upload.wikimedia.org/wikipedia/commons/6/66/Red-black_tree_example.svg
One of the 5 required properties is that all leaves are black.
A leaf is a node without a child, so that would only be 11 and 15 two links down from the root. So why is 1 and 25 black? They clearly have a child, so they are not leaves. Similarly, why is 6, 22, and 27 not black. They don't have children so they should be black.