@@ -222,7 +222,7 @@ case Left-Left:// Left-Left insertion, unbalanced \\B perform right rotation to
222222 for diagrams etc explaining rotations.
223223\\Expl}
224224\\In{
225- return rightRotate(t) \\B return rightRotate(t)
225+ return rightRotate(t) // raise Left-Left subtree to balance \\B return rightRotate(t)
226226\\In}
227227case Right-Right:// Right-Right insertion, unbalanced \\B perform left rotation to re-balance t
228228\\Expl{
@@ -233,7 +233,7 @@ case Right-Right:// Right-Right insertion, unbalanced \\B perform left rotation
233233 for diagrams etc explaining rotations.
234234\\Expl}
235235\\In{
236- return leftRotate(t) \\B return leftRotate(t)
236+ return leftRotate(t) // raise Right-Right subtree to balance \\B return leftRotate(t)
237237\\In}
238238case Left-Right:// Left-Right insertion, unbalanced \\B perform left rotation on the left subtree
239239\\Expl{
@@ -248,9 +248,10 @@ case Left-Right:// Left-Right insertion, unbalanced \\B perform left rotation on
248248\\In{
249249 perform leftRotate(left(t)); // raise Left-Right subtree \\B left(t) <- leftRotate(left(t));
250250 \\Expl{
251- The result returned is the new left(t).
251+ The result returned is the new left(t). This lowers the Left-Left
252+ subtree.
252253 \\Expl}
253- return rightRotate(t) \\B return rightRotate(t) after leftRotate
254+ return rightRotate(t) // raise Left-Left subtree to balance \\B return rightRotate(t) after leftRotate
254255\\In}
255256case Right-Left:// Right-Left insertion, unbalanced \\B perform right rotation on the right subtree
256257\\Expl{
@@ -265,12 +266,13 @@ case Right-Left:// Right-Left insertion, unbalanced \\B perform right rotation o
265266\\In{
266267 perform rightRotate(right(t)); // raise Right-Left subtree \\B right(t) <- rightRotate(right(t));
267268 \\Expl{
268- The result returned is the new right(t).
269+ The result returned is the new right(t). This lowers the Right-Right
270+ subtree.
269271 \\Expl}
270- return leftRotate(t) \\B return leftRotate(t) after rightRotate
272+ return leftRotate(t) // raise Right-Right subtree to balance \\B return leftRotate(t) after rightRotate
271273\\In}
272274// ==== rotation functions ====
273- leftRotate(t2) \\B leftRotate(t2)
275+ leftRotate(t2) // raises Right-Right + lowers Left-Left subtrees \\B leftRotate(t2)
274276\\Expl{
275277The edge between t2 and its right child is "rotated" to the left
276278(counter-clockwise), and the right child becomes the new root.
0 commit comments