3 ms·
> Each iteration of the outter loop moves the smallest element into `A[i]`. The first `i` iterations of the inner loop are just wasting time. In the first iter
by ColinWright 2y ago
> Each iteration of the outter loop moves the smallest element into `A[i]`. The first `i` iterations of the inner loop are just wasting time.
In the first iteration of the outer loop, i=1, and in that case the inner loop moves the largest element into A[1].
So I don't think you can be correct.
- anonymousd3vil 2y agoThis is similar to bubble sort but with the largest element appearing at the beginning index. Its a reverse Bubble Sort.
- ColinWright 2y agoExcept that when the routine finishes, the smallest element is in A[1].