AVL tree

AVL tree
TypeTree
Invented1962
Invented byGeorgy Adelson-Velsky and Evgenii Landis
Complexities in big O notation
Space complexity
Space
Time complexity
Function Amortized Worst Case
Search [1] [1]
Insert [1] [1]
Delete [1] [1]
Animation showing the insertion of several elements into an AVL tree. It includes left, right, left-right and right-left rotations.
Fig. 1: AVL tree with balance factors (green)

In computer science, an AVL tree (named after inventors Adelson-Velsky and Landis) is a self-balancing binary search tree. 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 O(log n) 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".[2] It is the oldest self-balancing binary search tree data structure to be invented.[3]

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.[4] Similar to red–black trees, AVL trees are height-balanced. Both are, in general, neither weight-balanced nor -balanced for any ;[5] that is, sibling nodes can have hugely differing numbers of descendants.

  1. ^ a b c d e f Eric Alexander. "AVL Trees". Archived from the original on July 31, 2019.
  2. ^ Adelson-Velsky, Georgy; Landis, Evgenii (1962). "An algorithm for the organization of information". Proceedings of the USSR Academy of Sciences (in Russian). 146: 263–266. English translation by Myron J. Ricci in Soviet Mathematics - Doklady, 3:1259–1263, 1962.
  3. ^ Sedgewick, Robert (1983). "Balanced Trees". Algorithms. Addison-Wesley. p. 199. ISBN 0-201-06672-6.
  4. ^ Pfaff, Ben (June 2004). "Performance Analysis of BSTs in System Software" (PDF). Stanford University.
  5. ^ AVL trees are not weight-balanced? (meaning: AVL trees are not μ-balanced?)
    Thereby: A Binary Tree is called -balanced, with , if for every node , the inequality
    holds and is minimal with this property. is the number of nodes below the tree with as root (including the root) and is the left child node of .