Red-Black TreesContents•Introduction•Red-Black Tree Operations•insert•delete•SummaryIntroductionRecall that, for binary search trees, although the average-case times for the lookup, insert, and deletemethods are all O(log N), where N is the number of nodes in the tree, the worst-case time is O(N). WecanguaranteeO(log N) time for all three methods by using a balanced tree -- a tree that always hasheight O(log N)-- instead of a binary search tree.A number of different balanced trees have been defined, including AVL trees, 2-4 trees, and B trees. Youmight learn about the first two in an algorithms class and the third in a database class. Here we will lookat yet another kind of balanced tree called a red-black tree.The important idea behind all of these trees is that the insert and delete operations mayrestructurethetree to keep it balanced. So lookup, insert, and delete will always be logarithmic in the number of nodesbut insert and delete may be more complicated than for binary search trees.A red-black tree is a binary search tree in which•each node has a color (red or black) associated with it (in addition to its key and left and rightchildren)•the following 3 properties hold:1.(root property) The root of the red-black tree is black2.(red property) The children of a red node are black.3.(black property) For each node with at least one null child, the number of black nodes onthe path from the root to the null child is the same.An example of a red-black tree is shown below:Operations on a Red-Black TreeAs with the binary search tree, we will want to be able to perform the following operations on red-blacktrees:•insert a key value (insert)