It's still the same, first of all:
Property 1. nodes are red or black
Nature 2. The root is black
Nature 3. All leaves are black (leaves are nil nodes)
Nature 4. If a node is red, its two sons are black
5. All simple paths from a
Summary
Bowen explores four key points: 1, a brief introduction to the red-black tree; 2, red-Black tree node data structure; 3, the color of the parent pointer field and the node of the red
First, Introduction
Balanced binary tree (balancedbinary or height-balanced)
Also known as the AVL tree. It is either an empty tree or a two-fork tree with the following properties: Its Saozi right subtree is a balanced binary tree, and the Saozi of the depth of the right
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 operat
On the principle of the red and black trees on the internet is quite a lot of resources, and the situation is a little complicated, so here I will no longer state, directly on the code bar:
debugging when you can call the sequence traversal to do, I in the previous blog provides PHP implementation of the two-tree graphics, with visual help can better help us to
The height expectation of a randomly constructed two-fork lookup tree is O (LGN), and does not mean that all two-fork lookup trees have a height of O (LGN). But for some binary search tree deformation, the performance of the basic operation of the dynamic set is always very good, such as red black
Introduced
Today we introduce another kind of balanced binary tree: The red and black trees, which were invented by Rudolf Bayer in 1972, were called balanced binary B-trees (symmetric binary b-trees) and 1978 by Leonidas J. Guibas and Robert Sedgewick changed into a more modern name: The red-
I recently studied the introduction to algorithms in the section about the Binary Search Tree and the red/black tree. Although the content of the red/black tree has not been completely
The next step is to introduce the red-black tree Insert, before inserting, let's first look at the nature of the red-black tree.1, each node is not red or black2, with the node is
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/
Reprinted please indicate the source: http://blog.csdn.net/mxway/article/details/38080315
Five properties of the red and black trees on Wikipedia below
1. nodes are red or black
2. The root is black.
3. All leaves are black (the
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 ded
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
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
Recently, because of the support for CCache to join the red-black tree, find the code that has been implemented as a reference, this only to find that the original implementation is problematic, but also blame my test case writing is not good, just the insertion of the test, I have read this code and caused confusion of friends to apologize.
This time, all the c
1. Insert Introductionthe first way to sort trees with two forks Add the node and mark it red. (Why not red?) Because if set to black, it will cause the root to the leaves of all paths, one path will have an extra black node, this is difficult to adjust. However, when set to a red
Red and black trees are self-balancing sorting trees, the advantage of self-balance is to reduce the traversal of the node, so the efficiency will be high. If a non-balanced two-fork tree is inserted in a sequential or reverse order, it is very easy to understand the rules of the red-
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.