CS C++ Quiz 10 (old 7) True or false: Insertion sort usually performs fewer swaps than selection sort. True or false: Quicksort can easily be performed on data in an array. The apstack class includes two pop member functions. Which of the following statements about those functions is true? (a) Since the apstack class is a template class, it is necessary for it to have two pop functions. (b) Since the apstack class has two constructor functions, it is necessary for it also to have two pop functions. (c) This is an example of function overloading: two functions with the same name but with a different number of parameters. (d) This is an example of templating: two functions that perform the same operations on objects of different types. Consider the following code segment: apstack S; int k; for (k = 1; k <= 5; k++) S.push(k); while (!S.isEmpty()) { cout << S.top() << " "; S.pop(k); cout << k << " "; } cout << endl; What happens when this code segment is executed? (a) A runtime error occurs due to an attempt to pop an empty stack. (b) The while loop never terminates. (c) The code executes without error, producing this output: 1 2 3 4 5 (d) The code executes without error, producing this output: 5 4 3 2 1 (e) The code executes without error, producing this output: 5 5 4 4 3 3 2 2 1 1 The function NumItems shown below was intended to count the number of items in its queue parameter Q, without changing Q itself. However, NumItems does not always work correctly. int NumItems(apqueue& Q) { int firstItem, oneItem; int count = 1; if (Q.isEmpty()) return 0; Q.dequeue(firstItem); Q.enqueue(firstItem); while (Q.front() != firstItem) { count++; Q.dequeue(oneItem); Q.enqueue(oneItem); } return count; } Which of the following best characterizes the queue parameters for which function NumItems will return the wrong value? (a) Empty queues. (b) Queues that contain exactly one item. (c) Queues that contain the same value at the front of the queue and elsewhere in the queue. (d) Queues that contain an odd number of items. (e) Queues that contain an even number of items. Show what the contents of this file will be after one Split operation and one MergeRuns operation of MergeSort. File: Becky Wendy Emma Cathy Jane Scarlett Ruth Shannon Jill Marilyn Mary Phoebe