The selection sort algorithm sorts by finding the smallest element of an array, then the next smallest element, and so forth, using Theta(n) time at each step where n is the number of elements remaining. It is and example of a DecreaseByConstant algorithm and runs in Theta(n2) in both the worst and the best case.

Like InsertionSort, selection sort can be implemented in-place, with the output array appearing as a prefix of the input array:

{{{SelectionSort(A)

}}}

Selection sort is more complicated than InsertionSort, has a slightly larger constant, is no faster asymptotically in the worst case, and is slower in the best case. InsertionSort is almost always a better choice.


CategoryAlgorithmNotes

SelectionSort (last edited 2007-12-25 23:42:20 by localhost)