The five properties

  1. Every node is red or black.
  2. Root is black.
  3. Every leaf (NIL) is black.
  4. Red nodes have black children.
  5. 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.