DSA Lab
Bubble sort visualizer
Walk along the list swapping neighbours that are out of order. After each pass the largest remaining value has bubbled to the end. Teaching, and tiny lists. With the early stop it notices an already sorted list in one pass.
Bubble sort: its cost, and how to use this tool
Time: best O(n), average O(n²), worst O(n²). Extra memory: O(1). Stable, in place.
Sort a ready-made input or your own numbers. The bars are the array; the code beside them (in Python, C, C++ or Java) marks the line that just ran, and every step is explained and worked out below the bars.
Lessons that use it
- Bubble, selection and insertion sort (Algorithms)Three O(n²) sorts, step by step: swapping neighbours, picking the minimum, and inserting into a sorted part.