Рет қаралды 1,342
Selection Sort is a fundamental and simple sorting algorithm
It strategically divides the unsorted list into two sections: sorted and unsorted.
In each pass, it finds the minimum (or maximum) element in the unsorted section.
That element is then swapped with the first element of the unsorted section, effectively placing it in its sorted position.
This process repeats until the entire list is sorted.
Worst-case performance
𝑂(𝑛^2) comparisons,
𝑂(𝑛) swaps
Best-case performance
𝑂(𝑛^2) comparisons,
𝑂(1) swaps
Average performance
𝑂(𝑛^2) comparisons,
𝑂(𝑛) swaps
Worst-case space complexity
𝑂(1) auxiliary