Insert The Node In Red Black Tree
properties:
~Insert
Node must be red.
~Arranged the color according to the Red Black Tree.
Root is always black
Every leaf which nil (null) is black.
If node is red then both children must be black or if node is red, then its parent must be black.
~Rotation
According to the cases.
There are case in given below.
~ Violation of properties of red black tree.
Case :
case 1. After insert.(New Node uncle is red).
1.Change the color of grandparent of new node.
2.Change the color of parent and uncle of new node.
~ New node unle is black and New node is right child of the parent.
Follow this :
1. Anti-clock wise Rotation of the grandparent of the new node.
~ New Node uncle is black and new node is left child of it's parent .
Follow this :
1.Clockwise rotation of the grandparent of new node.
2. Exchange color of the grandparent and parent of new node.