5 ms·
You would appear to be wrong, because A[1] ends up with the smallest element. Specifically, on each case when i=2 and higher, j will still start at 1, so A[1]
by ColinWright 2y ago
You would appear to be wrong, because A[1] ends up with the smallest element.
Specifically, on each case when i=2 and higher, j will still start at 1, so A[1] will still get referenced.
- jmholla 2y agoOn the first pass, A[1] ends up the largest element. On subsequent passes, it ends up with the smallest element in A[1:i].