This page seeks to explain how to implement a Red Black Tree insertion algorithm, as taught in CS400 at UW Madison.

- Refer to this Follow Along Guide as you complete the steps!
Determine if aunt of the newly inserted node is red or black. To do this, go up twice to the grandparent node of the newly inserted node, and go one node down on the opposite tree. This is the aunt node.

If aunt is red, turn the grandparent node red, and recolor the parent and the aunt node to black.

If aunt is black, check whether the newly inserted node is the same type of node as its parent (Left child or Right child).

If both are the same type of node (Left/Right child), rotate the parent and the grandparent, and then swap the colors of the parent and grandparent.

If both are not the same type of node (Left/Right child), rotate the child and the parent, in order to make them the same type of node, then refer to step 4.

CONGRATULATIONS! You have successfully learned the insertion algorithm for a Red Black Tree!