Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- node* del(node* root,int val)
- {
- if(root)
- {
- if(root->val==val)
- {
- if(!root->lft && !root->ryt)
- return NULL;
- else if(!root->lft)
- {
- root->ryt->parent=root->parent;
- return root->ryt;
- }
- else if(!root->ryt)
- {
- root->lft->parent=root->parent;
- return root->lft;
- }
- root->val=findMax(root->lft);
- root->lft=del(root->lft,root->val);
- }
- else if(root->val > val)
- root->lft=del(root->lft,val);
- else
- root->ryt=del(root->ryt,val);
- }
- return root;
- }
Add Comment
Please, Sign In to add comment