-->
当前位置:首页 > 题库 > 正文内容

程序填空题:RR Rotation

Luz4年前 (2021-05-10)题库1557
The function `RR_Rotation` is to do right-right 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 RR_Rotation( Tree T )
{
Tree L;

R = T->right;
T->right = R->left;
@@[R->left = T](2);
/* Update heights */
T->h = maxh(Height(T->left), Height(T->right)) + 1;
R->h = @@[maxh(Height(R->right), T->h)](2) + 1;

return L;
}
```





答案:
第1空:R->left = T

第2空:maxh(Height(R->right), T->h)

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。