Sorting
Watch sorting algorithms run one operation at a time: which values get compared, which ones swap, and how the array settles into order.
Visualisations
Bubble Sort
Watch bubble sort compare adjacent pairs and swap until the largest value reaches the end. Step through it one comparison at a time, or try your own numbers.
Merge Sort
Watch merge sort halve an array, sort each half, then merge the two sorted runs back into one. Step through every comparison, or try your own numbers.
Radix Sort
Watch radix sort distribute values into digit buckets and collect them back, one digit at a time. Step through every placement, or try your own numbers.
Counting Sort
Watch counting sort count occurrences, build prefix sums, then place each value at its final position. Step through every operation, or try your own numbers.
Side by side
| Algorithm | Best | Average | Worst | Space | Stable |
|---|---|---|---|---|---|
| Bubble Sort | O(n) | O(n²) | O(n²) | O(1) | Yes |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |
| Radix Sort | O(nk) | O(nk) | O(nk) | O(n + b) | Yes |
| Counting Sort | O(n + k) | O(n + k) | O(n + k) | O(n + k) | Yes |