Question: I. (20%) Consider selection sort. Instead of first finding the smallest element, we can sort n numbers stored in array A[0..n-1] by first finding the

 I. (20%) Consider selection sort. Instead of first finding the smallest

I. (20%) Consider selection sort. Instead of first finding the smallest element, we can sort n numbers stored in array A[0..n-1] by first finding the largest element of A and exchange it with A[n-1]. Then find the second largest element of A, exchange it with A[n-2]. Continue in this manner for the rest n-2 elements of A. 1) Write pseudocode for this algorithm including input and output. 2) Give the best case and worst case running times of this selection sort in -notation. 3) Apply the algorithm to the array A[0..6]-(P, R, O, G, R, A, M). Illustrate steps of the algorithm iterations Write a recursive version of the above selection sort and give its time efficiency (Extra credit). 4)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!