avl树平衡因子
什么是AVL树? (What is an AVL Tree?)
An AVL tree is a subtype of binary search tree. Named after it's inventors Adelson, Velskii and Landis, AVL trees have the property of dynamic self-balancing in addition to all the properties exhibited by binary search trees.
AVL树是二进制搜索树的子类型。 AVL树以其发明人Adelson,Velskii和Landis的名字命名,除了二叉搜索树显示的所有属性外,还具有动态自平衡的属性。
A BST is a data structure composed of nodes. It has the following guarantees:
BST是由节点组成的数据结构。 它具有以下保证:
- Each tree has a root node (at the top). 每棵树都有一个根节点(在顶部)。
- The root node has zero, one or two child nodes. 根节点具有零个,一个或两个子节点。
- Each child node has zero, one or two child nodes, and so on. 每个子节点都有零个,一个或两个子节点,依此类推。
- Each node has up to two children. 每个节点最多有两个孩子。
- For each node, its left descendants are less than the current node, which is less than the right descendants. 对于每个节点,其左后代小于当前节点,而当前节点小于右后代。
AVL trees have an additional guarantee:
AVL树有一个额外的保证:
- The difference between the depth of right and left subtrees cannot be more than one. In order to maintain this guarantee, an implementati