AVL (Adelson-Velskii
& Landis) Tree
.
Presented By
Sana Rahim
AVL Tree
A balanced binary search tree where
the height of the two subtrees
(children) of a node differs by at most
one. Look-up, insertion, and deletion
are O( log n), where n is the number of
nodes in the tree
Definition of height
Height: the length of the longest
path from a node to a leaf.
 All leaves have a height of 0
 An empty tree has a height of –1
AVL Rotations
To balance itself, an AVL tree may perform the following four
kinds of rotations
• Left rotation
• Right rotation
• Left-Right rotation
• Right-Left rotation
Insertion
14
17
11
7 53
4
14,
17,
11,
7,
53,
4,
13
13
14
17
7
4 53
11
13
Right Rotation
11
7
4
Insert: 12
14
17
7
4
53
11
13
12
First left Rotation then Right:
14
17
7
4
53
11
12
13
AVL tree is balanced.
14
17
7
4 53
12
13
11
Deletion of Node
14
17
7
4
53
11
12
8 13
Unbalanced
14
17
7
4
11
12
8 13
Balanced!
14
17
7
4
11
12
8
13
Questions

AVL Tree