- if(c < 0) {
- rightbottom->left = child;
- child->parent = rightbottom;
- rightbottom = child;
-
- node->left = child->right;
- child->right = node;
- node->parent = child;
- node = child->left;
- child->left = NULL;
- } else if (c > 0) {
- if(!child->right)
- break;
-
- leftbottom->right = child;
- child->parent = leftbottom;
- leftbottom = child;
-
- rightbottom->left = node;
- node->parent = rightbottom;
- rightbottom = node;
-
- node->left = NULL;
- node = child->right;
- child->right = NULL;
- } else {
- rightbottom->left = node;
- node->parent = rightbottom;
- rightbottom = node;
-
- node->left = NULL;
- child->parent = NULL;
- node = child;
- break;
- }
+ if((root->left = child->right))
+ child->right->parent = root;
+
+ child->right = root;
+ root->parent = child;
+
+ child->left = NULL;
+ grandchild->parent = NULL;
+
+ root = grandchild;
+ } else if (c > 0 && (grandchild = child->right)) {
+ leftbottom->right = child;
+ child->parent = leftbottom;
+ leftbottom = child;
+
+ child->right = NULL;
+ grandchild->parent = NULL;
+
+ rightbottom->left = root;
+ root->parent = rightbottom;
+ rightbottom = root;
+
+ root->left = NULL;
+
+ root = grandchild;