I inserted node 36 in the red black tree and the following red black tree resulted:

my problem is that how to handle double red in this special case? is it case 2 or 3?
I inserted node 36 in the red black tree and the following red black tree resulted:

my problem is that how to handle double red in this special case? is it case 2 or 3?
Based on Wikipedia's properties and cases...
36would be inserted under case 5, rotating22left.Wikipedia just says "the uncle is black", but, looking at the code, you'll see that that case triggers.
Note that the tree without
36was already invalid because property 5 (all paths from any given node to its leaf nodes contain the same number of black nodes) is not held:Assuming the insert order is
20, 15, 22, 30, 36...All nodes are inserted as red.
22would be inserted under case 2.30would be inserted under case 3, making22and15black and20red.36would be inserted under case 5, rotating22left.