In computer science, an AVL tree (named after inventors Adelson-Velsky and Landis) is a self-balancing binary search tree. It was the first such data structure to be invented. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this property. Lookup, insertion, and deletion all take time in both the average and worst cases, where is the number of nodes in the tree prior to the operation. Insertions and deletions may require the tree to be rebalanced by one or more tree rotations. The AVL tree is named after its two Soviet inventors, Georgy Adelson-Velsky and Evgenii Landis, who published it in their 1962 paper "An algorithm for the organization of information". AVL trees are often compared with red–black trees because both support the same set of operations and take time for the basic operations. For lookup-intensive applications, AVL trees are faster than red–black trees because they are more strictly balanced. Similar to red–black trees, AVL trees are height-balanced. Both are, in general, neither weight-balanced nor -balanced for any ; that is, sibling nodes can have hugely differing numbers of descendants. Definition Balance factor In a binary tree the balance factor of a node X is defined to be the height difference of its two child sub-trees. A binary tree is defined to be an AVL tree if the invariant holds for every node X in the tree. A node X with is called "left-heavy", one with is called "right-heavy", and one with is sometimes simply called "balanced". Properties Balance factors can be kept up-to-date by knowing the previous balance factors and the change in height – it is not necessary to know the absolute height. For holding the AVL balance information, two bits per node are sufficient. The height (counted as the maximal number of levels) of an AVL tree with nodes lies in the interval: where is the golden ratio and This is because an AVL tree of height contains at least nodes where is the Fibonacci sequence with the seed values Operations Read-only operations of an AVL tree involve carrying out the same actions as would be carried out on an unbalanced binary search tree, but modifications have to observe and restore the height balance of the sub-trees. Searching Searching for a specific