



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
AVL tree assignment - basic introduction and recommended for beginners
Typology: Assignments
Uploaded on 08/28/2021
1 document
1 / 6
This page cannot be seen from the preview
Don't miss anything!




differ at most 1. That difference should be exactly -1,0,1. Balance of the node v can calculate from fellow equation, balance = height of left sub tree of node v โ height of right sub tree of node v Balance for node a = height of left sub tree โ height of right sub tree = 2 โ 2 = 0 Balance for node b = height of left sub tree โ height of right sub tree = 1 โ 0 = 1 Balance for node c = height of left sub tree โ height of right sub tree = 0 โ 1 = -
Balance for node d = height of left sub tree โ height of right sub tree = 0 โ 0 = 0 Balance for node e = height of left sub tree โ height of right sub tree = 0 โ 0 = 0
average and worst cases.
used for rebalance it.
LL rotation โ Left-Left rotation RL rotation โ Right-Left rotation LR rotation โ Left- Right rotation
Double rotation - RL rotation, LR rotation
Worst case scenarios of runtime of Part a) BST Part b) AVL tree Insertion O(1) O(log n) Deletion O(n) Search O(n)