Algorithms

Selection sort

A sorting algorithm that each round finds the smallest of what's left and puts it at the end of the sorted part. Always O(n²) and unstable.

Example

[4, 1, 3] → finds 1 and swaps it with 4: [1, 4, 3] → finds 3: [1, 3, 4].

Test yourself: Selection sort

Selection sort

After selection sort's first round, index 0 holds the ___ element of all.

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.