A test asked me to implement a sorting algorithm that sorts an array that when the size is N > 1000 by Merge sort, otherwise by Quick sort with the pivot is chosen randomly. Then suppose the keys to compare consists of randomly distributed integers on [1, M]. How M should be for the above algorithm to run best?
I let Quick Sort handles the recursive call of Merge Sort if the size is <=1000. In my opinion, because of random keys, random pivots and Hoare's partition scheme isn't slowed down by repeated elements if M is much smaller than N, Quick sort will run at its best, and Merge sort runs the same for a specific array size regardless of keys distribution, so what is M used for here?