mysql 几种树的结构_数据结构中的几种树

在计算机科学中,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).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值