Not getting the desired result

Here is the link to the solution I have done.

hey you have to insert every element at the tail not at the head. Also have edited your merge function

node *mergeSort(node *a, node *b){
    if (b == NULL){
        return a;
    if(a == NULL){
        return b;

    node *c;
    if (a -> data < b -> data ){
        c = a;
        c->next = mergeSort(a -> next, b);
    else {
        c = b;
        c->next = mergeSort(a, b -> next);
    return c;

I was following prateek bhaiya’s approach.

He has also inserted at tail of linked list.

I mean the mergeSort function. I did what he has done in the video

is this what you are asking ? if no then attach a screenshot.

Yes, I have done this.

So now what issue are you getting in this ? your merge function will work fine now.

I mean I could not understand the code you wrote previously.

by doing node c we are declaring a new node, okay? after that we check using our if else statement that head of a linked list should be c or b.Now suppose we choose a , and make it equal to, now we also have to move forward so what c->next will do is recursively call the function and check again .That’s how it’s working. Now in this if you are unable to understand something then ask.

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.