AVL Tree Rotations
LL Rotation :
struct Node *LLRotation(struct Node *ptr) {
struct Node *ptrL = ptr -> left;
struct Node *ptrLR = ptrL -> right;
ptrL -> right = ptr;
ptr -> left = ptrLR;
ptr -> height = nodeHeight(ptr);
ptrL -> height = nodeHeight(ptr -> left);
if (ptr == root)
root = ptrL;
return ptrL;
}RR Rotation :
LR Rotation :
RL Rotation :
Contributed by Nitin Ranganath
Last updated
Was this helpful?