A selection sort can be described as an in-place comparison. This algorithm divides a collection or list of objects into two parts. The first is a subset of objects that have already been sorted, ranging from 0 to i, where i is the next object to be sorted. The second is a subset of objects that have not been sorted, ranging from i to n, where n is the length of the collection.
The selection sort algorithm works by taking the smallest or largest value in a collection and placing it at the beginning of the unsorted subarray by swapping it with the object at the current index. For example, consider ordering a collection in ascending order. At the outset, the sorted subarray will consist of 0 members, while the unsorted subarray will consist of all the members in the set. The selection sort algorithm will find the smallest member in the unsorted subarray and place it at the beginning of the unsorted subarray.
At this point, the sorted subarray consists of one member, while the...