Question: (1) The Insertion Sort below can output an ascending array. Please modify the pseudocode to make it output a descending array. (10 points) INSERTION-SORT(A)

(1) The Insertion Sort below can output an ascending array. Please modify

 

(1) The Insertion Sort below can output an ascending array. Please modify the pseudocode to make it output a descending array. (10 points) INSERTION-SORT(A) for j 1 2 3 5678 = 2 to A.length A[j] key = // Insert A[] into the sorted sequence A[1..j-1]. =j-1 while >0 and A[i]> key A[i+1] =A[i] 1=1-1 A[i+1] = key (2) Please give an array with 5 elements, which is the worst case of the modified insertion sort code. (5 points) (3) Please give an array with 5 elements, which is the best case of the modified insertion sort code. (5 points)

Step by Step Solution

3.43 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

lets first modify the pseudocode for the Insertion Sort algorithm to make it output a descending arr... View full answer

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 Algorithms Questions!