AVL tree is balanced binary search tree. When we try to add new node to the AVL tree, it may become un-balanced. Generally the node which is unbalanced is grand parent of the newly inserted node. To balance the AVL tree, we need to do rotations. There are two types of rotations.
- Single rotation: As the name says need to do one rotation (left or right) to balance the tree. In this there are two types of sub rotations
- Double rotation: need to do two rotations (left-right or right-left) to balance the tree. In this there are two types of sub rotations
No comments:
Post a Comment