程序填空题:LL Rotation
The function LL_Rotation is to do left-left rotation to the trouble-finder tree node T in an AVL tree.
c++
typedef struct TNode *Tree;
struct TNode {
int key, h;
Tree left, right;
};
Tree LL_Rotation( Tree T )
{
Tree L;
L = T->left;
= L->right;
L->right = T;
/* Update heights */
T->h = maxh(Height(T->left), Height(T->right)) + 1;
L->h = ;
return L;
}
答案:
第1空:T->left
第2空:maxh(Height(L->left), T->h) + 1
c++
typedef struct TNode *Tree;
struct TNode {
int key, h;
Tree left, right;
};
Tree LL_Rotation( Tree T )
{
Tree L;
L = T->left;
= L->right;
L->right = T;
/* Update heights */
T->h = maxh(Height(T->left), Height(T->right)) + 1;
L->h = ;
return L;
}
答案:
第1空:T->left
第2空:maxh(Height(L->left), T->h) + 1