Algorithms / 9 visualizations
Sorting Algorithm Visualizers
Eight classic sorts, a non-comparison radix sort and a head-to-head race.
Open the lab → Every one runs on your own input, step by step, with the code highlighted in Java, Python, C++, C or JavaScript. Free, no sign-up.
All sorting visualizations
- Bubble SortO(n²)
Walk through the array and swap any neighbors that are out of order. After each pass, the largest remaining value has bubbled to the end.
- Selection SortO(n²)
Find the smallest value in the unsorted part and swap it to the front. Repeat until nothing is left.
- Insertion SortO(n²)
Keep the left part sorted. Take the next value (the key) and slide it left past every bigger value.
- Shell SortO(n²)
Insertion sort, but first on values that are gap apart. Big gaps move far-away values quickly; the last pass with gap 1 is a normal insertion sort on an almost sorted array.
- Merge SortO(n log n)
Split the array in half until each piece has one value, then merge the pieces back together in order.
- Quick SortO(n²)
Pick a pivot, move smaller values to its left and bigger ones to its right, then sort each side the same way.
- Heap SortO(n log n)
Turn the array into a max-heap so the biggest value sits at index 0. Swap it to the end, shrink the heap by one, and repair it. Repeat.
- Counting SortO(n + k)
No comparisons at all. Count how many times each value appears, then write the values back from smallest to largest.
- Radix Sort (LSD)O(d·(n + 10))
Sort by the ones digit, then by the tens digit, keeping ties in their previous order. After the last digit the whole array is sorted, without comparing two values.