"Select"/find the smallest item and swap it with the item in the first place. Select/find the next smallest item and swap it with the item in the second place. And so on.
Algorithm
For each iteration:
1. Iteration #1: Consider the first thru the n'th items. When you're done, the smallest will be in its final position in the first spot; it no longer needs to be considered for swapping.
2. Iteration #2: Consider the secon thru the n'th items. When done, the second smallest will be in its final position.
3. Continue to iterate until the number of items being considered is just 1. You're done!
Exercise
In the table below, show what the data looks like after each iteration of the algorithm.
What is the Loop Invariant?
A "loop invariant" is a true statement you can make about the data at each step. It does not describe how the algorithm works.
Complete this sentence: "At the ith step of the algorithm ... "