You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AVL Tree/README.markdown
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,20 +45,21 @@ If after an insertion or deletion the balance factor becomes greater than 1, the
45
45
## Rotations
46
46
Each tree node keeps track of its current balance factor in a variable. After inserting a new node, we need to update the balance factor of its parent node. If that balance factor becomes greater than 1, we "rotate" part of that tree to restore the balance.
47
47
48
-
Example of balancing the unbalanced tree using *Right* (clockwise direction) rotation:
49
-

48
+
Example of balancing the unbalanced tree using *Right* (clockwise direction) rotation:
49
+

50
50
51
-
Let's dig into rotation algorithm in detail using the terminology:
51
+
For the rotation we're using the terminology:
52
52
**Root* - the parent not of the subtrees that will be rotated;
53
53
**Pivot* - the node that will become parent (basically will be on the *Root*'s position) after rotation;
54
54
**RotationSubtree* - subtree of the *Pivot* upon the side of rotation
55
55
**OppositeSubtree* - subtree of the *Pivot* opposite the side of rotation
0 commit comments