Question: Redo Exercise III, using heapsort instead of merge sort.
Exercise III: Suppose that the recursive quicksort receives an int parameter, depth, from the driver that is initially approximately 2 log N.
a. Modify the recursive quicksort to call merge Sort on its current subarray if the level of recursion has reached depth.
b. Prove that the worst-case running time of this algorithm is O(N log N).
c. Conduct experiments to determine how often merge Sort gets called.
d. Implement this technique in conjunction with tail recursion removal in Exercise 8.18.
e. Explain why the technique in Exercise II would no longer be needed.
Exercise II: Continuing from Exercise I, after part (a),
a. Perform a test so that the smaller subarray is processed by the first recursive call and the larger subarray is processed by the second recursive call.
b. Remove the tail recursion by writing a while loop and altering low or high, as necessary.
c. Prove that the number of recursive calls is logarithmic in the worst case.
Exercise I: The quicksort in the text uses two recursive calls. Remove one of the calls as follows.
a. Rewrite the code so that the second recursive call is unconditionally the last line in quicksort. Do so by reversing the if/else, and returning after the call to insertionSort.
b. Remove the tail recursion by writing a while loop and altering low.