- Check if tree is empty.
-
If tree is empty, then insert node as root and change color
to black.
- If tree is not empty, insert node as a red leaf node and perform
the appropriate repair operations.
Example of insertting a new node into an RBT.
Worst case O(log(n)).
For more information on Red Black Trees, you can visit https://pages.cs.wisc.edu/~cs400/readings/Red-Black-Trees/.