This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. Please help improve this article by introducing more precise citations.(May 2019) (Learn how and when to remove this message)
Selection sort
Class
Sorting algorithm
Data structure
Array
Worst-case performance
comparisons, swaps
Best-case performance
comparisons, swap
Average performance
comparisons, swaps
Worst-case space complexity
auxiliary
Optimal
No
Preview warning: Page using Template:Infobox algorithm with unknown parameter "stable"
In computer science, selection sort is an in-place comparison sorting algorithm. It has an O(n2) time complexity, which makes it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity and has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited.
The algorithm divides the input list into two parts: a sorted sublist of items which is built up from left to right at the front (left) of the list and a sublist of the remaining unsorted items that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right.
The time efficiency of selection sort is quadratic, so there are a number of sorting techniques which have better time complexity than selection sort.
In computer science, selectionsort is an in-place comparison sorting algorithm. It has an O(n2) time complexity, which makes it inefficient on large lists...
e., O(n2)) sorting algorithms More efficient in practice than most other simple quadratic algorithms such as selectionsort or bubble sort Adaptive, i...
exchange, selection, merging, etc. Exchange sorts include bubble sort and quicksort. Selectionsorts include cycle sort and heapsort. Whether the algorithm is...
allowed, bubble sortsorts in O(n) time, making it considerably faster than parallel implementations of insertion sort or selectionsort which do not parallelize...
for an out-of-order item, then insert the item in the proper place. Selectionsort: Find the smallest (or biggest) element in the array, and put it in...
comparison-based sorting algorithm which can be thought of as "an implementation of selectionsort using the right data structure." Like selectionsort, heapsort...
shaker sort, also known as bidirectional bubble sort, cocktail sort, shaker sort (which can also refer to a variant of selectionsort), ripple sort, shuffle...
T(n)=O(n)+T(0)+T(n-1)=O(n)+T(n-1).} This is the same relation as for insertion sort and selectionsort, and it solves to worst case T(n) = O(n2). In the most balanced...
Tournament sort is a sorting algorithm. It improves upon the naive selectionsort by using a priority queue to find the next element in the sort. In the...
computer science, merge sort (also commonly spelled as mergesort) is an efficient, general-purpose, and comparison-based sorting algorithm. Most implementations...
be used as well, such as selectionsort or merge sort. Using bucketSort itself as nextSort produces a relative of radix sort; in particular, the case...
includes a PartialQuickSort algorithm used in partialsort! and variants. Selection algorithm Conrado Martínez (2004). On partial sorting (PDF). 10th Seminar...
as an extreme case, selection in an already-sorted array takes time O ( 1 ) {\displaystyle O(1)} . An algorithm for the selection problem takes as input...
optimization. As an example, consider the sorting algorithms selectionsort and insertion sort: selectionsort repeatedly selects the minimum element from...
selection algorithm is to take the first or the last element of the list as the pivot, causing poor behavior for the case of sorted or nearly sorted input...
pancake sorting algorithm performs at most 2n − 3 flips. In this algorithm, a kind of selectionsort, we bring the largest pancake not yet sorted to the...
congruent to sorting algorithms. The section on the equivalence of priority queues and sorting algorithms, below, describes how efficient sorting algorithms...
queue in selectionsort leads to the heap sort algorithm, a comparison sorting algorithm that takes O(n log n) time. Instead, using selectionsort with a...
League draft, also called the NFL draft or (officially) the Annual Player Selection Meeting, is an annual event which serves as the most common source of...
works by first calling a subroutine to sort the elements in the set and then perform its own operations. The sort has a known time complexity of O(n2),...
"efficient", or "fast". Some examples of polynomial-time algorithms: The selectionsortsorting algorithm on n integers performs A n 2 {\displaystyle An^{2}} operations...
selection algorithm to find the kth smallest element in an unordered list, also known as the kth order statistic. Like the related quicksort sorting algorithm...
the list Selectionsort: pick the smallest of the remaining elements, add it to the end of the sorted list Smoothgamersort Other Bitonic sorter Pancake...
important. For example, bubble sort and timsort are both algorithms to sort a list of items from smallest to largest. Bubble sortsorts the list in time proportional...
comparison-based sorting algorithm. Heapsort can be thought of as an improved selectionsort: like that algorithm, it divides its input into a sorted and an unsorted...