Select Sort Simulation #4

This simulation will display the contents of array a after each pass.

MinValue  
   MinIndex   
  
  

1
for (i = 0; i < (n-2); i++) {
2
     minValue = a[i]; // select as lowest value
3
     minIndex = i; // keep track of where we found it
4
     for (j = (i + 1); j < n; j++)
5
          if (a[j] < minValue) { // then we found a new min
6
               minVale = a[j]; // the new lowest value
7
               minIndex = j; // was found at index j
8
                }
9
     a[minIndex] = a[i]; // move to unsorted area
10
     a[i] = minValue; // moves this into the correct position
11
     } // end i loop

Trace Tables
update this row
i
array a
 
a[0]
a[1]
a[2]
a[3]
a[4]
a[5]
a[6]
j