Create a named selectionSort
that implements selection sort on a passed IntArray
.
To ensure that you are implementing selection sort, you should also return
a List<Int>
containing the positions of the minimum value on each pass through the array.
Selection sort works by repeatedly finding the smallest value in an array and moving it into position. In the first iteration, we find the smallest value of the entire array (starting at index 0) and swap it to the front. Next, we find the smallest value of the array starting at index 1 and swap it to position 1. This continues until the remaining array has size 1, at which point we are done.
To receive credit, you'll need to follow these instructions carefully:
IllegalArgumentException
.Stuck? You may find these lessons helpful: