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
5.00 Ratings (1 Votes)
There are 3 Steps involved in it
Step: 1
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-text-image.webp)
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Step: 3
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started