AI engineering glossary · Data structures algorithms
What is selection sort?
Selection sort: A sorting method that repeatedly finds the smallest remaining item and swaps it to the next position of the sorted part. It always performs about n^2/2 comparisons but only up to n swaps.
Selection sort: an example
On [64, 25, 12, 22], the smallest, 12, is swapped to the front giving [12, 25, 64, 22], then 22 is chosen next.
Related terms
More Data structures algorithms terms
- Separate chaining
- Shortest path
- Sliding window
- Sorting
- Space complexity
- Space-time trade-off
- Stable sort
- String matching
Where you learn it
Selection sort is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.