Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(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
Step: 1
lets first modify the pseudocode for the Insertion Sort algorithm to make it output a descending arr...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started