A red-black tree (rbtree) is a binary search tree in which each node has also a color, which can be red or black.
It needs to have the following properties:

  • each node is either red or black
  • all leaves are black and NIL
  • if a node is red, then both child are black
  • each path between a node and a descendent leaf contains the same number of black nodes
  • root is always black (as a convention)
  • height is at most

When a node are inserted that change the height invariant, the tree is rearranged using the current coloring scheme. Once the tree is rearranged, it is repainted.

The height property is what allows to calculate its asymptotic complexity and performance.

OperationComplexity
Insertion
Recolouring
Deletion
Searching
Traversal (amortized)

See also

References