Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (node != NULL) {
- node->balance += d_balance
- if (node->balance == 0) {
- return;
- } else if (node->balance == -2) {
- if (node->left->balance == -1) {
- Tree_RotateRight (t, node);
- } else {
- Tree_RotateLeftRight (t, node);
- }
- return;
- } else if (node->balance == 2) {
- if (node->right->balance == 1) {
- Tree_RotateLeft (t, node);
- } else {
- Tree_RotateRightLeft (t, node);
- }
- return;
- }
- Node parent = node->parent;
- if (parent != NULL) {
- d_balance = (parent->left == node) ? -1 : 1;
- }
- node = parent;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement