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 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
lets first modify the pseudocode for the Insertion Sort algorithm to make it output a descending arr... View full answer
Get step-by-step solutions from verified subject matter experts
