The five properties
- Every node is red or black.
- Root is black.
- Every leaf (NIL) is black.
- Red nodes have black children.
- Every root-to-leaf path has same number of black nodes.
Advertisement
Consequence: balanced
Max height ≤ 2 × log(N+1). Never worse than 2× perfectly balanced.
Advertisement
Insert violation types
Newly inserted red node with red parent violates rule 4. Fix via recoloring or rotations depending on uncle's color.
Recoloring case
If uncle is red: recolor parent + uncle black, grandparent red. Recurse up.