Sorting Algorithm Visualizer
Watch how different sorting algorithms rearrange an array of bars step by step. Yellow = comparing, red = swapping, green = sorted, purple = pivot.
What is Sorting?
Sorting means arranging numbers in order (smallest → largest). Think of it like arranging books on a shelf by height. The coloured bars below represent numbers — watch how each algorithm rearranges them!
Current algorithm: Bubble Sort: Repeatedly compare neighbours and swap if out of order. Simple but slow — like sorting a hand of cards by swapping adjacent ones.
Starting Bubble Sort: repeatedly compare adjacent pairs and swap if out of order.
Big O — How Fast Does It Grow?
n = 12 barsThe O(n²) curve grows much faster than O(n log n). For 30 numbers, O(n²) does ~900 operations; O(n log n) does only ~147. Both curves share one scale, so heights compare honestly. Quick Sort's worst case, such as sorted input with the last item as pivot, follows the red O(n²) curve instead. The highlighted dot shows where n=12 sits on the active algorithm's curve.