Iam_Sandeep

Untitled

Aug 3rd, 2021
674
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct node *delete_contains(int v, struct node *h)
  2. {
  3.  struct node *t = NULL;
  4.  //if h is EMPTY return
  5.  if (h == NULL)
  6.  {
  7.   return NULL;
  8.  }
  9.  //if we found the data
  10.  if (h->data == v)
  11.  {
  12.   t = h->next;
  13.   free(h);//delete h
  14.   h=NULL;//avoid memory leak
  15.   return t;//return
  16.  }
  17.  else
  18.  {
  19.  // recursive call
  20.   h->next = delete_contains(v, h->next);
  21.   return h;
  22.  }
  23. }
RAW Paste Data