Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 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
Step: 1
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