Selection Sort is one among the 3 (others including Insertion Sort and Bubble Sort) comparison-based sorting algorithms. It has O(N^2) time complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and it has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory(or external memory) is limited. Selection sort is based on Brute force method.
- Find the smallest element in the array and exchange it with the element in the first position.
- Find the second smallest element in the array and exchange it with the element in the second position.
- Continue this process until the array is sorted.
Name | Best | Average | Worst | Memory |
---|---|---|---|---|
Selection sort | n2 | n2 | n2 | 1 |