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 subtree does not exceed 1. If the balance factor BF (Balancefactor) of the node in the two-fork tree is defined as the depth of the left subtree of the node minus the depth of its right subtree, the balance factor of all node
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 {
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 ngi
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
be found after the linked list, as for why the list is to save space, the list in memory is not continuous storage, So we can use memory more fully.Java's HashMapWhat does that have to do with the hashmap of our topic today? All right, do not square friends, into the subject. We know that the values in HashMap are all key,value, right, in fact, the storage here is very much like the above, the key will be mapped to the address of the data, and the value is in the list with this address as the h
The red and black trees (red-black tree) are one of many balanced search trees, so the time complexity of basic operations (query, delete, search) and so on in the worst case is O (LGN).13.1 The nature of red and black treesThe
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
About RB TreesThe red and black tree is a binary search tree, which adds a storage bit on each node to represent the color of the node, which can be red or black. By constraining any color from the root to the leaf's simple path, the red-
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 i
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 tree, B-tree, balanced binary tree (AVL tree), jumping table (not the exact tree, more or less the structure of
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
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 follo
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
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
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
Two forks The basic operation of the search tree can be done within O (h), however the height of the number is higher, and may not be faster than executing on the linked list. red and black trees are a guarantee in the search tree of the worst case time complexity O (LG (n))The nature of red and black trees
E
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-
Balanced binary tree and red black tree worst case analysis1. Classic Balanced binary treeThe Balanced binary tree (also known as the AVL tree) is a two-fork search tree with equilibrium conditions, with the most common theorem: a balanced binary tree is a two-fork lookup tree with a maximum height difference of 1 for each node of the Saozi right subtree . Because he is a concrete application of the two-fo
Java Improvement (27)-----TreeMapTreeMap 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-
Directory
Definition and nature
Rotating
Insert
Delete
Definition and natureRed-black tree, is a balanced "binary search tree".The red and black tree icons are as follows:Properties:
The knot is either red or black.
The root node is
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.