SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top