Red/Black (1), red/Black1. Red/black tree
The red/black tree is a self-balancing Binary Search Tree (BST). Each node follows the following rules:Property 1. nodes are red or black
Nature 2
This article mainly introduces 2-3 trees, and introduces the RB tree (red-black tree) by 2-3 treesComplete code attached2-3 Trees1.2-3 Trees2-3 Tree Concept:A 2-3 find tree, or an empty tree, or a tree consisting of 2-node, 3-node.2
Red-black tree, the height of the subtree can be changed, that is, the operation that can make it different from the general binary search tree is: rotation. Rotation can change the height of the sub-tree to maintain the property of the red/black tree:
The left-hand (X, Y are not T. Nil) is used to increase y and decrease X. It is mainly used to exchange parent-child relationships:
Left-rotate (t, x) y =
trees with the previous balancing operation on the 2-3 tree, which can correspond to each other, such as:Now to discuss the various situations:Case 1 Towards a 2-node Insert a new node at the bottom of the nodeFirst of all, let's look at the action of inserting a new node for a red-black tree with only one node:This i
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:
H
The red/black tree is a binary search tree. to delete the red/black tree, follow the rules of the Binary Search Tree. To delete node Z (5), delete the minimum value of Y in the right subtree of Z and then assign the value of Y to the Z node. :
Then we will consider the red and black trees.
1. The deleted node y is re
1. Red and black Tree natureA red-black tree is a self-balancing binary lookup tree (BST) in which each node adheres to the following rules:Property 1. The node is red or blackNature 2. The root node is blackNature 3. All leaves are blac
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 node, it may cause two consecutive red nodes to conflict, which can be adjusted by
, as stated below:
Figure14: CommonRCCircuit
The relationship between the output voltage at both ends of the capacitor and the power supply voltage is as follows:
The relationship between the voltage increase amplitude and the increase time (lagging time) is as follows:
T (/RC)
1
2
3
4
5
UC/us
0.632
0.865
0.95
0.98
0.993
black nodes;If the red-black rule is not met after inserting/deleting nodes in the red-black tree, the following correction method is used:1. Change the color of the node;2. Rotation;Red and Black tree knot.Template red and
mathematical induction method can prove that: at least 2BH (x)-1 inner nodes are included in the subtree with node x as root.Secondly, assuming that the height of the red-black Tree is H (the height of the root node is 0), it is ④ by nature that at least half of the nodes are black from the root node (excluding the root) to any simple path of the leaf node, so t
Internet ).
The definition of the red/black tree and the black height is given below:
A binary search tree that meets the following conditions (red and black) is calledRed/black tree:1. Each node is either red or black.
The previous blog mainly describes the basic concept of two-fork sorting tree and insert delete operation, it must be explained again: In a height of two-fork sorting tree, the implementation of dynamic collection operation query, insert and delete run time is O (h).The basic operational efficiency of the binary tree is determined by the shape of the tree, of course, the lower the height of the tree is better, obviously, the more evenly distributed tree, the lower the height. So, what's the prob
2-3-4 trees and red/black trees may look completely different. However, in a sense, the two are exactly the same.
There is a data item and two subnodes are called 2-nodes.
There are two data items and three sub-nodes called 3-nodes.
Three data items and four subnodes are called 4-nodes.
Rules for converting from 2
!!!Step Three:Look up: Black!!! It's black!!!Method Four:The first step:Open IE5.5 or above, or FireFox1.5 or above, and enter the destination URL to open the forum that needs to be hacked.Step Two:Take a certain size bricks or metal, such as hard objects, the center of your screen, throw!!!Step Three:Look up: Black!!! It's b
program design ". Experiment 1 Configuration
Black gold FPGA model: Cyclone II ep2c8q208c8
1. You have added five. V files to the experiment. After the compilation is successful, the hierarchy will be shown in another figure. Top_module file organization
Four other functional modules.
algorithm.
Each node of the red/black tree has one attribute.Key,3Pointers:Parent,Left,RightIn addition, there is an additional attribute:Color. It can only be in two colors: red or black,Of course, you can also add someKeyTo index the data. In addition to all the properties of the Binary Search Tree, the red/black tree also has the following5Point nature:
character equals ' G ', then the corresponding cup of tea should to be green. If some character equals ' B ', then the corresponding cup of tea should is black.
If There are multiple answers, print any of them. Examples Input
5 1 3 2
Output
Gbgbg
Input
7 2 2 5
Output
Bbgbgb
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.