doublerotation
struct AvlNode;
typedef struct AvlNode *Position;
typedef struct AvlNode *AvlTree;
struct AvlNode{
ElementType Element;
AvlTree Left,Right;
int Height;
}
static Position DoubleLeftRotationwithoutSingle(Position K3){
Position K1,K2;
K1=K3->Left;
K2=K1->Right;
K1->Right=K2->Left;
K3->Left=K2->Right;
K2->Left=K1;
K2->Right=K3;
K1->Height=Max(Height(K1->Left),Height(K1->Right))+1;
K3->Height=Max(Height(K3->Left),Height(K3->Right))+1;
K2->Height=Max(Height(k1),Height(k3))+1;
return K2;
}
static Position DoubleRightRotationwithoutSingle(Position k1){
Position K2,k3;
K3=K1->Right;
K2=K3->Left;
K1->Right=K2->Left;
K3->Left=K2->Right;
K2->Left=K1;
K2->Right=K3;
K1->Height=Max(Height(K1->Left),Height(K1->Right))+1;
K3->Height=Max(Height(K3->Left),Height(K3->Right))+1;
K2->Height=Max(Height(k1),Height(k3))+1;
return K2;
}
浙公网安备 33010602011771号