CS 12 - Assignment 7 - Linked Lists


CS 12 Homepage

Due via e-turnin by Tuesday 5/18, 11pm


Collaboration Policy:
Collaboration on home programming assignments is strictly FORBIDDEN.
Programs must represent YOUR OWN original work.
Sharing code or team-coding are not allowed. Copying code from ANY source (any book, current or past students, past solutions, the web, etc.) is not allowed.
Cooperation to the extent of helping to debug, or discussing the general approach to solving the problem is encouraged, but should never involve communicating code or even pseudo-code or explicit algorithms. Your code must be unique.



Write a function called merge_lists that takes two call-by-reference arguments that are pointer variables. These point to the heads of two linked lists of values of type int.
The two linked lists are assumed to be already sorted in the order smallest to largest - i.e. the number at the head is the smallest, the number in the next node is larger, etc.
Your function should return a pointer to the head of a new linked list that contains all of the nodes of the two original lists; the new list will be sorted in the same manner as the original lists, i.e. smallest to largest.
Note that your function will neither create nor destroy any nodes - it will simply re-order the nodes of the original two lists.
When the function returns, the two original pointer variable arguments should have the value NULL.