在计算机科学中,AVL树是最先发明的自平衡二叉查找树。在AVL树中任何节点的两个子树的高度最大差别为一,所以它也被称为高度平衡树。查找、插入和删除在平均和最坏情况下都是O(log
n)。增加和删除可能需要通过一次或多次树旋转来重新平衡这个树。AVL树得名于它的发明者G.M.
Adelson-Velsky和E.M.
Landis,他们在1962年的论文《An algorithm for the organization of
information》中发表了它。
节点的平衡因子是它的左子树的高度减去它的右子树的高度(有時相反)。带有平衡因子1、0或
-1的节点被认为是平衡的。带有平衡因子
-2或2的节点被认为是不平衡的,并需要重新平衡这个树。平衡因子可以直接存储在每个节点中,或从可能存储在节点中的子树高度计算出来。
AVL树的基本操作一般涉及运作同在不平衡的二叉查找树所运作的同样的算法。但是要进行预先或随后做一次或多次所谓的"AVL旋转"。
Radix tree
http://en.wikipedia.org/wiki/Radix_tree:
In computer
science, a patricia trie or radix trie) is a space-optimized
trie
data structure
where each node with only one child is merged with its child. The
result is that every internal node has at least two children.
Unlike in regular tries, edges can be labeled with sequences of
characters as well as single characters. This makes them much more
efficient for small sets (especially if the strings are long) and
for sets of strings that share long prefixes.
A common extension of radix trees uses two colors of nodes,
'black' and 'white'. To check if a given string is stored in the
tree, the search starts from the top and follows the edges of the
input string until no further progress can be made. If the
search-string is consumed and the final node is a black node, the
search has failed; if it is white, the search has succeeded. This
enables us to add a large range of strings with a common prefix to
the tree, using white nodes, then remove a small set of
"exceptions" in a space-efficient manner by inserting them
using black nodes.
As an optimization, edge labels can be stored in constant size
by using two pointers to a string (for the first and last
characters).