1. Show that the running time of the merge-sort algorithm on an n-element sequence is , even when n is not a power of two.

  1. An algorithm that sorts key-value entries by key is said to be straggling if any time two entries and have equal keys, and appears before in the input, then the algorithm places after in the output. Describe a change to the merge-sort algorithm to make it straggling.

  1. Of the possible inputs to a given comparison-based sorting algorithm on a list of elements, what is the absolute maximum number of inputs that could be correctly sorted with just comparisons? Prove your answer.

  1. Suppose you are throwing a fancy dinner party with guests total. When a guest walks through the front door, they check their coat in and continue to the party. However, the coat check mixes up all of the coats during dinner, so that afterward each guest receives a random coat when they prepare to leave. In other words, each guest gets their own coat with probability . What is the expected number of guests who get their correct coat?

  1. Suppose we are given two n-element sorted sequences, and . Each of these sequences have distinct elements, but there might be repeated elements between the sequences. Write the pseudocode for an time function that takes and as arguments and returns a new sorted sequence which is the intersection of and .