AVL Trees
AVL Trees - Introduction
- Motivation: Keep search tree balanced
- All leaves are at same level
- Basic ideas:
- An AVL tree is a Binary Search Tree
- At each node, the heights of the left and right subtrees
differ by zero or one
- Nodes are inserted as normal and the tree is rotated
to maintain balance
- AVL trees do these operations in lg n time (maintaining balance):
- insert a key
- search for a key
- delete the value at a location
- List operations:
- search for ith item
- insert a value at a location
- Named after 2 inventors: Adelson-Velsky and Landis (1962)
- Implementation is somewhat complicated and so Red-Black trees are more common