Prove that the DoubleMinMaxSort algorithm below is also inco

Prove that the DoubleMinMaxSort algorithm below is also incorrect. Input: data: array of integers Input: n: length of data, must be even Output: permutation of data such that data[1]

Solution

MinMaxsort:

1.Set p:=0,q:=n-1 //n is the number of elements

2.while p<q do:

Reeat steps 3 to 6

3.Minimum(a,p,q) //pass array p,q to find minimumm element of current array

4.Maximum(a,p,q). //pass array,p,q to find maximum element of current array

5.Set p:=p+1 //increment p

6.set q:=q+1 //increment q

7.End while

8.Print sorted array //end of algorithm

 Prove that the DoubleMinMaxSort algorithm below is also incorrect. Input: data: array of integers Input: n: length of data, must be even Output: permutation of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site