left_right_rotate that I wrote
struct Node*left_right(struct Node *x){
struct Node*a=x->left;
struct Node*b=a->right;
struct Node*c=b->right;
struct Node*d=b->left;
b->left=a;
b->right=x;
x->left=d;
a->right=c;
b->height=max(height(b->left),height(b->right))+1;
x->height=max(height(x->left),height(x->right))+1;
return b;
}
struct below
struct Node {
int data;
struct Node* left;
struct Node* right;
int height;
};
AVL that I read before
if (balance < -1 && key < node->right->data) {
node->right = rightRotate(node->right);
return leftRotate(node);
}
My way of writing is brute,rotate in place directly.The way I read right_rotate firstly,then left_rotate.Did I write is right?