Select Sort Simulation #2

Demonstrating that the list of numbers to be sorted can be seen as having two parts, a sorted part on the left, and an unsorted part on the right.
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
i
array a
 
a[0]
a[1]
a[2]
a[3]
a[4]
a[5]
a[6]
j

MinValue  
   MinIndex