/* Right- Left Rotation */ avl_node *avlTree::rl_rotation(avl_node *parent) { avl_node *temp; temp = parent->right; parent->right = ll_rotation(temp); return rr_rotation(parent); }
/* Left- Right Rotation */ avl_node *avlTree::lr_rotation(avl_node *parent) { avl_node *temp; temp = parent->left; parent->left = rr_rotation(temp); return ll_rotation(parent); }
WDBKeyIndex::WDBKeyIndexNode *WDBKeyIndex::rl_rotation(WDBKeyIndexNode *parent) { WDBKeyIndexNode *temp; temp = parent->right; parent->right = ll_rotation (temp); return rr_rotation (parent); }
WDBKeyIndex::WDBKeyIndexNode *WDBKeyIndex::lr_rotation(WDBKeyIndexNode *parent) { WDBKeyIndexNode *temp; temp = parent->left; parent->left = rr_rotation (temp); return ll_rotation (parent); }
/* Balancing AVL Tree */ avl_node *avlTree::balance(avl_node *temp) { int bal_factor = diff(temp); if (bal_factor > 1) { if (diff(temp->left) > 0) temp = ll_rotation(temp); else temp = lr_rotation(temp); } else if (bal_factor < -1) { if (diff(temp->right) > 0) temp = rl_rotation(temp); else temp = rr_rotation(temp); } return temp; }
WDBKeyIndex::WDBKeyIndexNode *WDBKeyIndex::balance(WDBKeyIndexNode *temp) { int bal_factor = diff (temp); if (bal_factor >1) { if (diff (temp->left) > 0) temp = ll_rotation (temp); else temp = lr_rotation (temp); } else if (bal_factor < 1) { if (diff (temp->right) > 0) temp = rl_rotation (temp); else temp = rr_rotation (temp); } return temp; }