Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

AVL Tree

According to Wikipedia:

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 n 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.

Take a look at the following AVL-Tree :-

AVL-Tree

Animation showing the insertion of several elements into an AVL tree. It includes left, right, left-right and right-left rotations.

Shown below is an AVL tree with balance factors (green)

AVL-Tree

Complexity

Average

Operation Complexity
Space
Search
Insertion
Deletion

AVL Tree Rotations

Left-Left Rotation

Left-Left Rotation

Right-Right Rotation

Right-Right Rotation

Left-Right Rotation

Left-Right Rotation

Right-Left Rotation

Right-Right Rotation

References