what is the error in my merge funcion
CPP Linked List - Merge two sorted Linked Lists
what is the error in my merge funcion
CPP Linked List - Merge two sorted Linked Lists
@ayush1213 hey ayush your logic is seem wrong make a recursive function for merge this
node * merge(node * a ,node * b ){
if(a==NULL){
return b;
}
else if(b==NULL){
return a;
}
node * c;
if(a->data<=b->data){
c=a;
c->next=merge(a->next,b);
}
else{
c=b;
c->next=merge(a,b->next);
}
return c;
}
@jaiskid sir i writed down recursiv e but i want to try iterative approach can u tell the error in my code where i m doing mistake