Question: Prove that the MinMaxSort algorithm below is not a correct sorting algorithm. Note that the input size must be even. Input: data: array of integers
Prove that the MinMaxSort algorithm below is not a correct sorting algorithm. Note that the input size must be even. Input: data: array of integers Input: n: length of data, which must be even Output: a permutation of data so that data[1] lessthanorequalto data[2] lessthanorequalto ... lessthanorequalto data[n] Algorithm: MinMaxSort if n lessthanorequalto 1 then | return data end min = Array(n/2) max = Array(n/2) for i = 1 to n/2 do | mm [i] = min { data [2i - 1], data [2i] } max[i| = max {data [2i - 1], data [2i] } end return the concatenation of min and max
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
