recategorized by
636 views
0 votes
0 votes
struct node* foo(struct node* a, struct node* b)

{

   struct node* result, *rec;

   if(a==null) return b;

   else if(b==null) return a;

   else

   {

     rec=foo(a->next,b->next);

     result=a;

     a->next=b;

     b->next=rec;

     return result;

}

}
recategorized by

1 Answer

0 votes
0 votes
suppose there is only one linked list and a and b will go upto last and second last node and then swapping of last node and second last node will occur.

Related questions

2 votes
2 votes
1 answer
2
thor asked Nov 18, 2016
1,937 views
0 votes
0 votes
1 answer
3
Mrityudoot asked Feb 25
144 views
How can we find the highest element in a singly linked list in O(1)? We are free to use any extra space.