12th Chapter Two Fork Search tree
All keys of the >= Zuozi all key,<= right subtree
On a two-fork search tree with a height of H, the operations Search,minimum,maximum,successor,predecessor,insert and delete on the dynamic collection can be completed in O (h) time.
h>= (LGN downward rounding)
As with the fast sort algorithm, its average performance is closer to the best case.
The desired height of the randomly constructed binary search tree is O (LGN).
All kinds of operation please check it yourself.
13th chapter red and Black Tree
is a (approximate) balanced two-fork search tree. The time complexity of the basic dynamic set operation can be guaranteed to be O (LGN) in the worst case scenario.
Ensure that no path is twice times longer than the other path.
1 each node is either red or black.
The 2 root nodes are black.
3 each leaf node (NIL) is black.
4 If a node is red, its two sub-nodes are black.
5 for each node, the same number of black nodes are included on the simple path from the node to all its descendant nodes.
Black high bh (x): The number of black nodes on any simple path that reaches a leaf node from a node x (without the node).
lemma 13.1 The height of a red-black tree with n internal nodes is at most 2LG (n+1).
All kinds of operation please check it yourself.
The 14th chapter of data structure expansion
14.1 Dynamic Sequential Statistics
Quickly finds the number of small I in a collection, or gives the position of a specified element in the full order of the collection.
Sequential statistics Tree: Modifies the red-black tree to include the size of the subtree that is the root of this node.
The method of the Nineth chapter O (n). The sequential statistics tree can reach O (LGN). Of course, it takes time O (n) to establish a red-black tree first.
Increase the number of nodes with the X-root subtree (except Sentinel).
When you insert a DELETE element, the time to maintain the red-black tree is O (LGN).
14.2 How to expand data structures
Four steps:
1 Selecting an underlying data structure
2 Determining the additional information to be maintained in the underlying data structure
3 Verify that basic modifications on the underlying data structure can maintain additional information
4 Designing some new operations
Expansion of the red and black trees:
theorem 14.1 (expansion of the red and Black tree) set F is the attribute of the red black Tree T expansion of n nodes, and it is assumed that the value of x,f for any node depends only on the information of Nodes X, X.left, and X.right, and may also contain X.LEFT.F and X.RIGHT.F. Then we can maintain the F-values of all the nodes of T during the insert and delete operations, and do not affect these two operations O (LGN) progressive time performance.
14.3 Interval Tree
Step 1 Basic data structure
Red and black trees, each node x contains an interval attribute x.int, and the keyword for x is the low-end point of the interval x.int.low.
Step 2 Additional Information
X.max represents the high-end point maximum for all intervals in a subtree that is rooted in X.
Step 3 Maintain additional information
X.max = Max (X.int.high, X.left.max, X.right.max)
Step 4: Design a new operation
Interval-search (T,i)
x = T.root
While x! = T.nil and I does not overlap X. int
If x. left! = T.nil and X. Left.max >= I. Low
x = x. Left
else x = X.right
return x
The theorem 14.2 any one execution of Interval-search (t,i), or returns a node whose interval overlaps with I, or returns T.NIL, at which time the interval without any nodes in the tree T overlaps with i.
Introduction to algorithms notes--12th to 14th chapter data Structure (ii) tree