Selection Sort
Last updated
Was this helpful?
Last updated
Was this helpful?
selection sort is an introductory level sorting scheme and its idea is straightforward: find the minimal number in each traverse of the unsorted part of list and replace it with first element on unsorted part of list to become a member of the sorted list, until the unsorted list is empty.
Note: the comparison step between index i and min value is complementary to improve the efficiency in case the element itself has to swap with itself.
takes (𝒩 - 1) + (𝒩 - 2) + ... + 0 ≈ 𝒩2 / 2 compares and 𝒩 exchanges.
No matter how the presortedness of inputs, the algorithm running time is quadratic. It is worth noted that selection sort scheme should not be used in most of scenarios except for cases that desire minimal cost of element exchanges. Therefore, according to , selection sort running time is Ο(n2).