I'm implementing a function where I would need to delete nodes based on given data and add the same time, I'll be carrying out this operating until my linked list reaches a NULL pointer.
At the same time, I need to also test whether my list is empty and print and another message and prevent the process above for being executed is there any way I can implement this?
void del(Node*&p, int k)
{
  if(ptr!=NULL)
  {
    if(ptr->data==k)
    {
      cout<<"Random Data"<<endl;
      Node*temp;
      temp=p;
      p=p->next;
      delete temp;
    }
    else
      del(p->next,k)
  }
}
Is there any way I can implement the same without recursion?
 
     
     
    