The red-black tree is Another variant of the AVL tree, and he can also maintain a sense of balance in the process of dynamic change, and the worst case scenario for a red-black tree is only the complexity of $o\left (\log n \right) $ , and below we will see that For insertion we have another implementation method that is easier than the AVL tree, not recursive. before we talk about technical details , we
Next to the previous article.
Insert the red/black tree!
The deletion of the red/black tree is further considered in various situations.
First, consider the single support of the red/black tree, that is, only the parent node has one child node and the other is null. In this case, there is only one situation, that is, the parent node is
http://cmsblogs.com/?p=1013 original source.TreeMap implementation is the implementation of red-black tree algorithm, so to understand the treemap must have a certain understanding of red and black trees, in fact, the name of this blog is called: According to the red-black tree algorithm to analyze the implementation of TREEMAP, But it's better to be consistent w
I. Introduction to red and black treesThe red-black tree is a balanced two-fork search tree, which is a commonly used data structure in computer science, and the most typical application is the implementation of data structures such as maps.Red and black trees have the following restrictions:1. The node must be red or black2. The root node is black3. All the leaf
Small black skirt System Marketing mode customization development find Chenyang 150-1315-1740 (Electric/Micro)Small black skirt pattern development small black skirt system development small black skirt custom development small black skirt app develop small
Original:Complete simple red-black tree algorithmThe recent set of rules, weekly sharing an algorithm, last week is the first week, sharing is the red and black trees, the following is the summary of their own study, the feeling of the Internet is not particularly clear, or is written in a particularly complex, not a little organized.One, red black tree nature1.
The previous article introduced the 2-3 lookup tree, you can see that the 2-3 find tree can ensure that after inserting elements can maintain the balance of the tree, the worst case is all the child nodes are 2-node, the height of the tree is lgn, thus guaranteeing the worst case of time Complexity. however, 2-3 trees are more complex to implement, this paper introduces a simple implementation of 2-3 tree data structure, that is, red-black trees (red-
Introduction to algorithms is good, but it is a headache to read pseudocode. I always want to have a c-language version of Introduction to algorithms.
I studied the red/black tree a few days ago and translated it into C language. Compiled and tested on vc6.0. A cview class is written to show the effect.
Header file rb_tree.h
# Ifndef rb_tree_h# Define rb_tree_h
Enum nodecolor {Red = 0, black = 1 };
Typede
A red-black tree is a two-prong search tree with color attributes for each node, with a color of red or black. In addition to the general requirements of the binary search tree, we have added the following additional requirements for any valid red-black tree:Nature 1. The nodes are red or black.Nature 2. The root is black.Nature 3. All leaves are
Author: July January 9, 2011
-----------------------------
Reference:I. The Art of Computer Programming Volume III. Introduction to Algorithms, Second EditionIII. The Annotated STL SourcesIV. WikipediaV, Algorithms In C Third Edition
VI. My first three articles on the red and black trees:
Article 1: teach you a thorough understanding of the red and black trees:
Http://www.bkjia.com/kf/201104/87322.html
Arti
OverviewAbout the basic knowledge of red and black trees in the previous article has been introduced, want to learn more about red and black tree can refer to the article "Data structure-red black tree", here is only simple to nginx in the red and black tree source of the analysis, Nginx red and
About the balance of the red and black trees-Conditions for deleting nodes [reprinted]
There have never been any good articles or implementations about algorithm deletion on the Internet. I will write them down here to facilitate future use.
The delete operation is always performed on a node with only one child or a leaf node, and will never be performed on a node with two children. The successor function is called only when there are two children in
Http://www.cnblogs.com/yangecnu/p/3627386.htmlThe previous article introduced the 2-3 lookup tree, you can see that the 2-3 find tree can ensure that after inserting elements can maintain the balance of the tree, the worst case is all the child nodes are 2-node, the height of the tree is LGN, thus guaranteeing the worst case of time complexity. However, 2-3 trees are more complex to implement, this paper introduces a simple implementation of 2-3 tree data structure, that is, red-
The previous article introduced the 2-3 lookup tree, you can see that the 2-3 find tree can ensure that after inserting elements can maintain the balance of the tree, the worst case is all the child nodes are 2-node, the height of the tree is LGN, thus guaranteeing the worst case of time complexity. However, 2-3 trees are more complex to implement, this paper introduces a simple implementation of 2-3 tree data structure, that is, red-black trees (red-
I. Red/black tree Overview
Similar to the AVL tree we have learned before, the red and black trees maintain a balance between the binary search trees through specific operations during insertion and deletion operations to achieve high search performance. However, since the emergence of the red and black trees, the AVL tree has been put in the museum. It is said t
I. Characteristics of red and black trees1. The node can only be red or black.2. The root node is black.3. Leaf node (NIL) is black.4. The child node of the red node must be a black node.5. The path to the descendant nodes of any node that reaches the node contains the same
subtree of the parent node of P.(3) If the left and right subtrees of the deleted node p are not empty, there are two ways:
Set PL to the left or right child node of P's parent node Q (depending on p is the left and right child node of its parent node Q), set PR to the right child node of the middle order forward node s of the P node (s is the most right node of PL, which is the largest node in the PL subtree).
In order to replace the point of P node with the pre-order or successor
Without authorization, shall not be reproduced privately, or be held liableContact author [email protected] get authorizationReprint please indicate the author and sourceMany of the online red and black trees are not analyzed clearly insert delete all kinds of situations is how to come, most of them the analysis of the picture is very complex, in fact, these conditions are extremely simple, I am here to deduce how the situation is how to do not explai
1. Red and black tree (Red-black trees) Introduction:The Red-black tree (RBT) can be said to be a non-strict balanced version of the Binary-search tree. Correspondingly, the Balanced binary tree (Balanced binary trees) is also called the AVL tree (because it is g.m. The tree Adelson-velsky and E.M Landis invented in 1962 is a strictly balanced version of Binary-s
Delete operations are more complex than inserts. First, let's look at some of the characteristics of red and black trees. These are my random list, for everyone's reference.1, the red node Father black child must be black. (Nil is a black node)2, single branch node, can only be bla
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.