In-depth understanding of red-black trees

For the principle and algorithm of red-black tree, I recommend everyone to read this blog: A detailed introduction to the principle and algorithm of red-black tree (1)

Here, I want to write some of my own experience, how to make the tree meet the rules of red-black tree in the process of color change and rotation. Please read it in conjunction with the blog above.

Insert case 1:

Insert case 2:


Insert case 3:


Cases of deletion (4 types):


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325909362&siteId=291194637