Avl WSTR
Avl WSTR
Avl WSTR
// Perform rotation
x->right = y;
y->left = T2;
// Update heights
y->height = max(height(y->left), height(y->right)) + 1;
x->height = max(height(x->left), height(x->right)) + 1;
return x;
}
// Perform rotation
y->left = x;
x->right = T2;
// Update heights
x->height = max(height(x->left), height(x->right)) + 1;
y->height = max(height(y->left), height(y->right)) + 1;
return y;
}
return root;
}
// No child case
if (temp == nullptr) {
temp = root;
root = nullptr;
} else // One child case
*root = *temp;
delete temp;
} else {
// Node with two children, get the inorder successor
Node* temp = minValueNode(root->right);
return root;
}
int main() {
Node* root = nullptr;
return 0;
}