在AVL树C中调用旋转功能

问题描述

我有这段代码可以rightRotate子树:

void rightRotate(mynode **parentPtr,mynode *child)
{
    // make sure the arguments are valid for a right rotation
    assert(parentPtr != NULL && child != NULL && child->left != NULL);

    // save the three node addresses involved in the rotation
    mynode *F = child;
    mynode *D = F->left;
    mynode *E = D->right;

    // perform the rotation
    *parentPtr = D;
    D->right = F;
    F->left = E;
}

树结构为:

typedef struct tree mynode;   // differences between naMetag and type????
struct tree{                    // tree node struct
    int value;
    int key;
    char color;
    struct tree *left;
    struct tree *right;
};

我的问题是:我应该如何调用函数

示例:我有一棵树,我想右旋转son,因为第一个参数是指向节点的指针的指针,第二个参数是指向节点的指针,我该如何写电话吗?

//...some code...
//I have two pointers to nodes : parent and son
rightRotate ( ???,son)// I didn't get the first argument,what I should write?
//some code...

P.S。 :这段代码来自另一篇文章,对于这个小小的“垃圾邮件”感到抱歉,但是我对这个简单的功能以及为什么以这种方式工作感到非常困惑。有人可以再解释一下我吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)