Question: Prove that BadSort ( below ) is not a correct sorting algorithm. Input: data: array of integers Input: n : size of data Output: Permutation

Prove that BadSort (below) is not a correct sorting algorithm.
Input: data: array of integers
Input: n : size of data
Output: Permutation of data such that
data[1]data[2]dotsdata[n]
Algorithm: BadSort
for i=n-1 to 1 step -1 do
Consider every ith value of data, starting at data 1;
if two of these values are out of order then
Swap them;
end
end
return data;
 Prove that BadSort (below) is not a correct sorting algorithm. Input:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!