We have the unsorted array A[1...n]. Find the largest key in the unsorted portio
ID: 670725 • Letter: W
Question
We have the unsorted array A[1...n]. Find the largest key in the unsorted portion of the array (initially the entire array s unsorted) and swap this with the last position in the unsorted section. This last position is now considered part of the sorted portion. This procedures continues untill all the elements in the array are sorted.
(a) Write the above algorithm in pseudo-code to sort A (sorting function only).
(b) How many comparisons will be made in
i. Worse case
ii.Average case
iii.Best case
Explanation / Answer
worse case : O(n^2).
average case:log2(n!).
best case :