Node* mergeSort(Node* head)
{
if(head==NULL || head->next==NULL)
return head;
Node *s,*f;
s=head;
f=head;
while(f!=NULL && f->next!=NULL)
{
s=s->next;
f=f->next->next;
}
Node *h1,*h2;
h1=head;
h2=s->next;
s->next=NULL;
Node *h11=mergeSort(h1);
Node *h22=mergeSort(h2);
return merge2lists(h11,h22);
}
In the above code while finding the middle of the linked list
case -1:getting segmentation fault if we use s=head and f=head;
case-2: showing the correct answer if we use s=head and f=head->next;
so pls tell me what is the cause of getting segfault in the first case ???