




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth exploration of avl trees, a self-balancing binary search tree algorithm. Various aspects such as tree rotations, insertions, and deletions. Avl trees ensure good performance by maintaining a balance between the height of left and right subtrees.
Typology: Study notes
1 / 8
This page cannot be seen from the preview
Don't miss anything!





22-0: Binary Search Trees
22-1: Balanced BSTs
22-2: Balanced BSTs
22-3: AVL Tree insert
22-4: AVL Tree insert
22-5: Tree Rotation
22-6: Tree Rotation
22-7: Tree Rotation
A
B
X Y
Z
A
X B
Y Z
Right Rotation
22-8: Tree Rotation
A
B
X Y
Z
A
X B
Y Z
Left Rotation
22-9: AVL Tree Insert
22-10: AVL Tree Insert
1
2
3
Left Rotate
around this edge
22-13: AVL Tree Insert
1
2
3
22-14: AVL Trees
22-15: AVL Tree Insert
(Examples using whiteboard / visualization) 22-16: AVL Tree Insert
22-17: AVL Tree Insert
22-18: Double Rotation
1
2
5
3
Insert a 4
22-19: Double Rotation
height = 1
height = 2
height = 3
height = 4
height = 1
22-20: Double Rotation
height = 1
height = 2
height = 3
height = 4
height = 1
22-26: AVL Tree Delete
22-27: AVL Trees
22-28: AVL Trees
N (0) = 1 N (h) = N (h − 1) + N (h − 2)
22-29: AVL Trees
N (0) = 1 N (h) = N (h − 1) + N (h − 2) + 1
N (h) = N (h − 1) + N (h − 2) + 1 ≥ (3/2)h−^1 + (3/2)h−^2 + 1 ≥ (3/2)h−^2 (1 + 3/2) + 1 ≥ (3/2)h−^2 (5/2) + 1 ≥ (3/2)h^ + 1 ≥ (3/2)h 22-30: AVL Trees
22-31: AVL Trees