Question: Algorithm design and Analysis 3. (1) The Insertion Sort below can output an ascending array. Please modify the pseudocode to make it output a descending
3. (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 for j = 2 to 4.length 2 key ADI 3 // Insert A[] into the sorted sequence A[1.. j - 1]. 4 i=j-1 5 while i > O and Ali > key 6 Ali + 1) = Ali 7 i=i-1 8 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
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
