Assume that we have an Mystery-Sort(A), which takes an array A of length n as input, sorts the numbers in A in non-decreasing order, and returns the sorted array.
We do not know whether the algorithm implemented by Mystery-Sort is stable. I need a procedure that takes an array of n integers and returns the sorted array in non-decreasing order, but i need the procedure to be stable.
How can i achieve this the pseudo-code of a stable sorting procedure Stable-Sort(A), which pre-processes and/or postprocesses the elements in A in O(n) time, makes only one call to Mystery-Sort, and returns the sorted array in non-decreasing order.