I am getting segmentation fault around line 18


fixed the code
this is a very delicate problem, u need specific checks for null pointer exceptions, where u were doing mid->next = NULL
there were cases when mid was returned as NULL so i used temp to store the previous node and made it’s next as NULL