Example #1
0
/*
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);
}
Example #2
0
/*
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);
}
Example #3
0
WDBKeyIndex::WDBKeyIndexNode *WDBKeyIndex::rl_rotation(WDBKeyIndexNode *parent)
{
    WDBKeyIndexNode *temp;
    temp = parent->right;
    parent->right = ll_rotation (temp);
    return rr_rotation (parent);
}
Example #4
0
WDBKeyIndex::WDBKeyIndexNode *WDBKeyIndex::lr_rotation(WDBKeyIndexNode *parent)
{
    WDBKeyIndexNode *temp;
    temp = parent->left;
    parent->left = rr_rotation (temp);
    return ll_rotation (parent);
}
Example #5
0
/*
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;
}
Example #6
0
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;
}