Red-Black Tree Insertion Repair Operations

Used when there is a red property violation in a Red-Black Tree (in other words, when a red node has a red child).

Case 1: Null or Black Aunt

  1. See if red child, red parent, and grandparent are in a straight line:

  2. Rotate and color swap:

Case 2: Red Aunt

  1. Recolor:

  2. Check color of grandparent's parent:

More information on Red-Black Trees can be found here.