Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- node* remove(int x, node* t)
- {
- node* temp;
- if(t==NULL)
- return NULL;
- else if(x< t->data)
- t->left = remove(x, t->left);
- else if(x>t->data)
- t->right = remove(x, t->right);
- else if (t->left && t->right)
- {
- temp = findMin(t->right);
- t->data = temp->data;
- t->right = remove(t->data, t->right);
- }
- else
- {
- temp = t;
- if(t->left==NULL)
- t=t->right;
- else if(t->right==NULL)
- t=t->left;
- delete temp;
- }
- return t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement