Selection Sort: Tracing Exercise

  • Trace selection sort algorithm on a given sequence of data.
  • Understand selection sort well enough to implement it.

Please run the selection sort code in "debug" mode for the following sequence of values:

$$ 14, 10, 23, 34, 6, 17, 50, 14 $$

You can use the unit test in SortingAlgorithmTest for this purpose.

Exercise complete the following trace table.

Making sense of the table!

Each row of the table above represents a complete inner pass through the selection sort algorithm. Two full passes have been filled as an example of the sort. The arrow in each row indicates where the smallest element in the unsorted part should go.

Solution