Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. node* remove(int x, node* t)
  2. {
  3. node* temp;
  4. if(t==NULL)
  5. return NULL;
  6.  
  7. else if(x< t->data)
  8. t->left = remove(x, t->left);
  9. else if(x>t->data)
  10. t->right = remove(x, t->right);
  11. else if (t->left && t->right)
  12. {
  13. temp = findMin(t->right);
  14. t->data = temp->data;
  15. t->right = remove(t->data, t->right);
  16. }
  17. else
  18. {
  19. temp = t;
  20. if(t->left==NULL)
  21. t=t->right;
  22. else if(t->right==NULL)
  23. t=t->left;
  24. delete temp;
  25. }
  26. return t;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement