There is no doubt about using the tree for search. The binary tree has now been written into all the basics.AlgorithmCourse, although not all it posts requireProgramPersonnel have mastered basic data structures and algorithms, but the improvements to the search tree have not been interrupted for decades, and this technology is in key R & D processes and innovative products, proven to be extremely valuable.
Origin
The red and black tree RB tree is an important improvement to the binary search tree. He was proposed by German professor Bayer in 1972 .... structured Ric binary B-trees, but an article from guibas And Sedgewick in 1978ArticleAfter its advent, this data structure was publicly known as the red and black trees-the name helps to recall the basic definition and important features of the red and black trees.
Currently, the red/black tree is a very important basic data structure, which can be found in introduction to algorithm and Linux kernel. as it has been widely studied, the standard definition, important properties, and operations of the red and black trees do not have much mystery. They can be expressed in a list.
The standard definition of the Red-black tree consists of five statements. The Concise Expression is that the red-black tree assigns a color attribute to each node and uses it to maintain a semi-balance. in the red and black trees, the distance between any two leaves and the root is no more than twice.
The original document can be downloaded at the Springer Website: http://www.springerlink.com/content/qh51m2014673513j/
Operation
For a tree with strong restrictions, the random insertion and deletion operations are extremely destructive. Therefore, like a balanced binary tree, a rotation operation is required to maintain the defined conditions. The performance of this data structure and algorithm can also be measured by the efficiency of insertion and deletion, which is very effective.
The rule of rotation is as follows: X replaces the position of Y and converts Y to the subnode of X. X's original subnode beta is converted to the subnode of Y.
An interesting phenomenon is that the rotation of the red/black tree does not change the result of the previous traversal.
After the rotation Operation is designed, the insert/delete operation step can be used to ensure that the definition is not violated.
The insert operation is similar to the general search binary tree. To maintain a balance, the insert operation needs to be colored and rotated, so the overall insertion complexity is O (lg n ).
The delete operation is slightly more complex than the insert operation. The operation is performed based on the normal tree node deletion, and then the color is adjusted and rotated. The complexity of the implementation is that the RB tree has several boundary conditions that need to be processed separately. In fact, improvements have been introduced in the structure design to simplify these situations. That is, any valid data node is an inner node, and all the boundary nodes are a false node, which only acts as a token in various operations. The complexity of the delete operation is also O (lg n ).
Use
The red/black tree and many other balanced binary trees are suitable for maintaining datasets of the set and map classes. Although HASH lists are often used to implement map and set (such as various data structures in Java), the implementation of balanced binary trees has some advantages that cannot be replaced. First, the fact that a balanced binary tree is a binary tree search determines the efficiency of simply sorting elements. second, if you want to perform set operations such as comparison and merge, you need to use the binary tree implementation form.
A tree similar to a red-black tree but more suitable for Directly Reading and Writing disk data is a B-tree, which is also proposed by Bayer.
Reference
Http://www.eli.sdsu.edu/courses/fall96/cs660/notes/redBlack/redBlack.html
Http://sunland.gsfc.nasa.gov/info/scheme/Red-Black_Trees.html