The next few articles will introduce a balanced tree structure:
Height of the tree is O ( )
Wherein two balanced binary tree: AVL and red-black tree . They are suitable for internal storage of references
A tree structure: the B-tree , it is greater than 2. Adapted external storage references (for example, a large dictionary is stored on disk)
The above structures may be balanced tree O (logn) implemented by the operation of the dictionary and ranking operation when used in the worst case. When the index table represents a linear balanced tree, operation get, insert, erase when used as O (logn)
Split tree: height is O (n), but also in a single operation with dictionaries split tree is O (n), but the sequence u operations comprising each vote which is only O (ulogu) when used
Second, the asymptotic time various dictionaries able to compare the structure of the new
The following functions are used in Θ
Third, the summary
map and multimap using the STL is red-black tree structure to ensure search, insert, delete operations have several levels of performance time
On actual runtime performance, AVL and red-black tree are similar; in contrast, when the split tree u embodiment comprising a sequence of operations, with less time. In addition, the implementation is relatively simple split tree
AVL and red-black tree is a "spin" to maintain balance:
AVL tree can take up to one rotation for each insert, delete each takes up to O (logn) rotations
Red-black tree for each insert and delete operations, only need one rotation
In most applications, this difference does not matter, because one rotation Θ (1) only when used. However, once the rotation is not completed within the time constants for applications that require balance, the difference is very important. For example, balance-first search tree (McCreight) is one such application. Priority balanced search tree is used to describe an element having a two-dimensional key at this time, the number of each keyword is a pair (x, y). It is a priority queue of about y, but it is also about the x-search tree. In such a tree, each turn require time-consuming O (logn). If a red-black tree to describe the balance-first search tree, because every time you insert or Deus requires only one rotation, the desired insert or delete operation the total time is still O (logn). When using the AVL tree, the deletion time becomes O ( )
Although the contrast the smaller dictionary can be processed in memory, AVL tree, red-black tree and split tree can provide higher performance, but a large dictionary, they are not appropriate . When the dictionary is stored on disk, you need to use a larger degree, the height of the smaller search tree, trees such as B-