ℹ️ Bubble Sort – Explanation
Idea— Bubble Sort makes multiple passes through the array. In each pass, adjacent elements are compared and swapped if needed. The largest element "bubbles" to the end of the unsorted portion — like an air bubble rising to the top.
Complexity — O(n²) comparisons and swaps in the worst case. With the early-exit optimization (no swap in a pass → done), the algorithm finishes in O(n) on already-sorted arrays. Memory: O(1) — in-place, no auxiliary array needed.
Properties
- Stable: Yes – equal elements retain their relative order, since swaps only occur on strict inequality.
- In-place: Yes – no auxiliary array needed, O(1) memory.
1 / 28
ArrayKlick = Wert bearbeiten · Rechtsklick = Element löschen
64
034
125
212
322
411
590
6+
_Start: Array mit 7 Elementen. Bubble Sort (aufsteigend) vergleicht benachbarte Paare und „blubbert“ das Maximum ans Ende des unsortierten Bereichs.
TauschVerglichen (kein Tausch)Sortiert (final)