Plzz tell me why merge sort dont work in this code

Nikhil, you arent using the correct method for building the list… Try to use the following approach as :

void insertAtTail(node* &head,int data)
{
if(head == NULL)
{
head = new node(data);
return;
}
node *tail = head;
while(tail->next != NULL)
{
tail = tail->next;
}
tail->next = new node(data);
return;
}

void buildList(node* &head, int n)
{
while(n>0)
{
int data;
cin>>data;
insertAtTail(head,data);
n–;
}
}