Determine the asymptotic running time of the sorting algorithm maxSort.
Algorithm maxSort(A)
Input: An integer array A
Output: Array A sorted in non-decreasing order
1. for j <- n-1 down to 1 do
2. m <- 0
3. for i = 1 to j do
4. if A[i] > A[m] then m <- i
5. exchange A[m], A[j]
Can you say anything about the "best-case" function $B_{maxSort}(n)$?
With a question like this, what is the way to tackle it? I have tried counting number of executions per line, but I can't translate it into asymptotic notation. My intuition is that it has something to do with $n^2$ due to the nested for loop, but I am not sure about this.