I am working on AVL Trees in Scheme. I have a problem with the rotation when the left subtree outweighs the right subtree of the given node. If the balance factor of L is -1, two different rotations are needed. The first rotation is a left rotation with L as the root. The second is a right rotation with P as the root. I did the first one, when comes the second part, i am stuck.
I used this helper function;
(define (avl-fix-helper1 avl)
((= (balance-factor (bst-left avl)) 1) (right-rotate avl))
((= (balance-factor (bst-left avl)) -1) (left-rotate (bst-left avl))) (else avl)))
There must be something in second condition to rotate the tree clockwise. What should i do ?