Selection Sort

Fill in the blanks

Selection Sort is a comparison-based sorting algorithm. It operates by dividing the input list into a and an region, repeatedly selecting the smallest (or largest) element from the unsorted region and moving it to the end of the sorted region. The algorithm operates in-place and works by repeatedly selecting the minimum element from the unsorted portion and swapping it with the unsorted element. This process continues until the entire list is sorted.



The time complexity of selection sort is O() in all cases—best, average, and worst. This is because selection sort always performs a linear scan to find the minimum element for each position in the array. Despite its simplicity, the quadratic time complexity makes selection sort inefficient for large datasets compared to more advanced sorting algorithms such as and .



Selection Sort is an in-place sorting algorithm, which means it requires a minimal amount of extra . Therefore, the space complexity of Selection Sort is O(), indicating that it uses a constant amount of additional memory regardless of the input size. One of the main advantages of Selection Sort is that it is easy to understand and implement, making it a great choice for teaching sorting concepts. However, the performance of Selection Sort is subpar for large datasets, with a time complexity of O(n²).

Keywords

sorted | mergesort | storage | quicksort | first | 1 | | unsorted |