search
Log In
0 votes
205 views
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;

}

}
in Programming 205 views
0

list1 :- 1 → 2 → 3  → 4

list2 :- 5 → 6 → 7  → 8  → 9

 

result:- 1 → 5 → 2 → 6 → 3  → 7 → 4 → 8  → 9

Please log in or register to answer this question.

Related questions

4 votes
1 answer
1
285 views
I was trying to implement the Linked List code in C. It compiles fine but doesn't give any output. What seems to be the error? I think I messed up at passing pointer references as function parameters. My Code (Insert At Beginning): #include <stdio.h> ... to the head node(pointer to pointer) to the function. - Return the modified head node by the function. Please read about Reference Semantics.
asked Apr 26, 2017 in Programming RahulVerma 285 views
0 votes
1 answer
2
447 views
What kind of linked list is best to answer question like “What is the item at position n?” a) Singly linked list b) Doubly linked list c) Circular linked list d) Array implementation of linked list
asked Aug 19, 2018 in Programming pradeepchaudhary 447 views
1 vote
0 answers
3
386 views
Let P be a single linked list.Let Q be a pointer to an intermediate node 'X' in the list.What is the worst case time complexity of best known algorithm to delete the node 'X ' from the list
asked Nov 25, 2017 in Programming saipriyab 386 views
5 votes
1 answer
4
1.4k views
What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list? O(n) O(1) θ(n2) θ(n)
asked Nov 14, 2017 in Programming hacker16 1.4k views
...