c is changing on every node why c should return as c should be on last node
Why c is returning
Hi @kingshuk441,
lets take an example
list1- 1,3 list2-2,4
1)a=1, b=2, since a<b, c=a=1,
and c->next= solve(a->next,b)
now when we go into above recusion,
a=3,b=2,since b<a, c=b=2(since c is local variable, it takes value 2) and we return c=2
and c->next = (a,b->bext)
now a=3 and b=4. and do on recusrion returns
1->2->3->4.
try solving the recursion on ppr. If u still have any doubt, feel free to post them here.
Hope dis helps.