# Linked List Problem

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;

}

}
0

list1 :- 1 → 2 → 3  → 4

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

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

## 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.
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
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
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)