Name: _____________________________________ Honor Code Acknowledgment: _________________ Random Quiz 9 CPS 100, Fall 1994 November 7, 1994 Problem: Sorting with John Barleycorn Consider the following code for implementing a merge sort of two linked lists. void MergeSort(Node * & list) // postcondition: list is sorted in non-decreasing order { if (list != NULL) { Node * first; Node * second; SplitList(list,first,second); MergeSort(first); MergeSort(second); list = Merge(first,second); } } part A: Does list need to be reference parameter? why/why not part B: Write the function prototype/header for the function SplitList so that the function MergeSort above will work as intended. part C: If SplitList executes in O(n) time for a list of n elements, what is the complexity of the implementation of MergeSort above? Why? part D: If first has m elements and second has n elements, what is the complexity of Merge(first,second) (assuming a good implementation)? Why? part E: The code below is the body of an implementation of SplitList. Add a statement(s) as needed to make it work properly. if (list != NULL) { first = list; Node * temp = list; second = list; while (temp->next != NULL) { temp = temp->next->next; second = second->next; } // statement needed here } Canine Order True or False: It never makes sense to use an O(n^2) sort since O(n log n) sorts exist. Justify your answer (briefly).