re-write the chapter on the red and black trees written a year ago. The red/black tree is a very popular Self-adjusted balanced binary sorting tree. generally, he gives us a complicated impression. He has many cases and must be careful with the rotation. Some people once said on TL that during an interview with a company, they were asked to implement the red/black tree. He doesn't think it makes sense. Few people can remember so many cases without referring to textbooks. in this chapter, I will show you the most concise implementation of the Red/black tree that I have ever seen. To what extent is it concise? I bet you can easily pass the above interview-wow, the red and black tree can be as simple as this ! This implementation comes from Dr. Chris okasaki's research at Carnegie Mellon University (CMU. He inspired me to implement AVL Tree and splay tree in the same way. This chapter describes the red and black trees. The general content is as follows: 1. introduction -- let's take a look at the fatal weakness of a common sorting binary tree and give the concept of tree rotation. 2. definition of the Red-black tree -- Let's see why the nature of the Red-black tree solves the balance problem and is better than the sorting binary tree. 3. insert -- we provide a mathematical definition of the algorithm inserted into the red/black tree. Here is the essence of this chapter. 4. delete-delete is not a problem, but we need to show how complicated deletion is than insertion. 6. traditional implementation-Let's look at the complexity of the traditional red/Black Tree Insertion Algorithm and make further comparative analysis. We will leave the traditional deletion algorithm for practice. 7. other words full text in https://sites.google.com/site/algoxy/rbtree because Google site cannot be accessed in China, so I put a copy in the iteye attachment. http://liuxinyu95.iteye.com/blog/1068508 all Source Code can be obtained on GitHub: https://github.com/liuxinyu95/AlgoXY |