ℹ️ Selection Sort – Explanation
Idea— Selection Sort divides the array into a sorted left portion and an unsorted right portion. Each pass finds the minimum (or maximum) of the unsorted region and swaps it with the first unsorted element. The sorted region grows by one, the unsorted shrinks.
Complexity — Always O(n²) comparisons, regardless of input — no early exit possible. However, at most n−1 swaps (one per pass), making Selection Sort attractive when write operations are expensive.
Properties
- Stable: No – swaps can change the relative order of equal elements.
- In-place: Yes – O(1) extra memory.
1 / 20
ArrayKlick = Wert bearbeiten · Rechtsklick = löschen
64
025
112
222
311
4+
_Start: Selection Sort sucht in jedem Pass das Minimum im unsortierten Bereich und tauscht es an die richtige Position.
aktuelles Minimum (▼)Tausch✓ sortiert