The above 3 cases are also considered conversely while the parent of Z is to the right of its own parent. All the different kind of cases can be illustrated through an instance. Let a red-black tree drawn below with a node z
Before the execution of any case, we have to first verify the position of P(Z) i.e. if it is towards left of its parent, then the above mention cases will be executed however, if it is towards the right of its parent, then the above three cases are assumed conversely.
Now, it is seen that Z is towards the left of its parent .Thus, the above cases will be executed and another node called y is assigned that is the uncle of Z and now cases to be executed are as follows:
Case 1: Property four is violated as both z & parent (z) are red
Now, let us verify to see which case is executed.
Case 2: The application of this case results in given Figure
Case 3: The application of this case results in below given Figure
At last, it resulted in perfect Red-Black Tree.