Red Black Trees (RBTs) are data structures that hold nodes in a binary search tree with additional constraints put on the structure. Those include:
These criteria produce some interesting properties of RBTs, namely that their height is always O( log n ) complexity, which is only the best case scenario for general BSTs.
To insert a node into a Red Black Tree, simply follow these steps:
This should result in a valid RBT with no property violations! Happy coding :)