Selection sort
Sorting by repeatedly finding the minimum of the unsorted suffix and placing it in its correct position.
Selection Sort
Selection Sort divides the list into a sorted prefix and an unsorted suffix. In each of the iterations, it finds the smallest element in the unsorted suffix and swaps it into the next position of the sorted prefix. After iterations, the first elements are in their final sorted positions.
Example
How It Works Step by Step
For a = [5, 3, 8, 1, 9, 2]:
Summary
| Case | Complexity |
|---|---|
| Worst / Average / Best |