Академический Документы
Профессиональный Документы
Культура Документы
As we know insertion and deletion of node/data from AVL Tree can leave
behind the tree to be unbalanced. (I.e. violates AVL-ness property of the tree)
So the idea behind maintaining the AVL-ness of an AVL tree is that whenever
we insert or delete an item, and if we have violated the AVL-ness property
of the tree, we must then restore its AVL-ness property by performing a set of
manipulations on the tree and these manipulation are known as Rotation.
There are two cases in single rotation. Right Rotation and Left Rotation"
Right Rotation
Left Rotation
Y
Z
X
Insert X here
Need of Right Rotation in this case
Insert Z here
Need of Left Rotation in this case
Req
There are two cases in double rotation. Left-Right and Right-Left Rotation.
Left-Right Rotation
Right-Left Rotation
X
Y
Insert Y here
NeedRotation
of Left-Right
Rotation
Single
(Outside
Case)
Insert Y here