4 ms·
I don't see why it's at all surprising. Each iteration of the outter loop restuls in the smallest element moving into `A[i]`. And then the first `i` iteratio
by jlarocco 2y ago
I don't see why it's at all surprising.
Each iteration of the outter loop restuls in the smallest element moving into `A[i]`. And then the first `i` iterations of the inner loop are just wasting time.
- 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].