Given 2 linked lists sorted in ascending order, write a function that will merge these lists into a single sorted list without copying the list contents. The node structure is of the form: struct Node { int value; struct Node *next; };
Sigiloso
Tough one... consider this for the kernel of the algorithm: while (list_a->next && list_b->next) { list_a_tmp=list_a->next; list_b_tmp=list_b->next; if (list_a->value value && list_a->next->value > list_b->value) { list_a->next=list_b; list_a=list_a_tmp; } else if (list_b->value value && list_b->next->value > list_a->value) { list_b->next=list_a; list_b=list_b_tmp; } else if (list_a->value value && list_a->next->value value) { list_a=list_a_tmp; } else { list_b=list_b_tmp; } }