AVL tree

It's height balanced tree

Height is balanced by balance factor. Balance factor (BF) = height of left sub tree - height of right sub tree

Valid FB values = {-1, 0, 1}. BF = |lh-rh| <= 1

Node is balanced if |lh-rh| <= 1

Node is unbalanced if |lh-rh| > 1

All rotations :
1. Left Left (LL) Rotation
2. Right Right (RR) Rotation
3. Left Right (LR) Rotation
4. Right Left (RL) Rotation

Idea behind rotations :

Height vs Node analysis






Comments

Popular posts from this blog

SQL basic interview question

gsutil Vs Storage Transfer Service Vs Transfer Appliance