C07-Quicksort/7.1.md
Using Figure 7.1 as a model, illustrate the operation of PARTITION on the array A = [13, 19, 3, 5, 12, 8, 7, 4, 21, 2, 6, 11].
AnswerWhat value of q does PARTITION return when all elements in the array A[p...r] have the same value? Modify PARTITION so that q = (p+r)/2 when all elements in the array A[p...r] have the same value.
AnswerIt will return r. So we have to modify the code in case the worst situation.
Give a brief argument that the running time of PARTITION on a subarray of size n is Θ(n).
AnswerBecause we just iterate the array once.
How would you modify QUICKSORT to sort into nonincreasing order?
AnswerChange the condition A[j] <= x to A[j] >= x
Follow @louis1992 on github to help finish this task.