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
Post a Comment