Mergesort linkedlist

question–>
https://practice.geeksforgeeks.org/problems/sort-a-linked-list/1
code–>

Node* mid1(Node* head){
       Node* f=head;
       Node* s=head;
       while(f!=NULL and f->next!=NULL){
           f=f->next->next;
           s=s->next;
       }
       return s;
   }
   Node* Mergell(Node* head1,Node* head2){
       if(head1==NULL){
           return head2;
       }
       if(head2==NULL){
           return head1;
           
       }
       Node* c=NULL;
       if(head1->data<head2->data){
           c=head1;
           c->next=Mergell(head1->next,head2);
       }
       else{
           c=head2;
           c->next=Mergell(head1,head2->next);
       }
       return c;
   }
Node* mergeSort(Node* head) {
    // your code here
    if(head==NULL || head->next==NULL){
        return head;
    }
    Node* mid=mid1(head);
    Node* a=head;
    Node* b=mid->next;
    mid->next=NULL;
    a=mergeSort(a);
    b=mergeSort(b);
    Node*  newnode=Mergell(a,b);
    return newnode;
    
}

it is showing segmentation fault!!

@tusharaggarwal272 are u there?

Hello @sheikhhaji18 please wait i am checking.

Hello @sheikhhaji18 i am unable to find what is the error you can raise the doubt again so some other TA may help you.

@tusharaggarwal272 tushar thanks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.