Merge Sort Linked List

CODE: Click Here

I am getting no output on my code, can some explain the error?

PS
give standard input as:

1
4
1 3 5 7
3
2 4 6

Hey! your insert_tail function is not working correctly as you haven’t written return statement in it. I have rectified your code of insert_tail() you can refer this :

  void insert_tail(int n){
    node *temp = new node;
    temp -> value = n;
    
    if(head==NULL){
      head = temp;
	  return;
    }
    node *tail = head;
    
    while(tail->next!=NULL){
      tail = tail -> next;
    }
    
    tail -> next = temp;
	return;
	
  } 

Hope this helps you :slight_smile:

1 Like

Thanks a lot for your help.