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] greaterthanorequalto data [2] greaterthanorequalto ... greaterthanorequalto data [n] Algorithm: MinMaxSort if n greaterthanorequalto 1 then | return data end min = Array (n/2) mar = Array(n/2) for i = 1 to n/2 do | min[i] = min [data [2i 1], data[2]} | 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
