Sorting Algorithms Visualizer

Compare five classic sorting algorithms step by step.
Interactive simulation
Insertion Sort
Avg: O(n²)
Comparisons0
Writes / swaps0
Step0
AlgorithmBestAverageWorstAuxiliary SpaceCore Idea
Insertion SortO(n)O(n²)O(n²)O(1)Grow a sorted prefix
Merge SortO(n log n)O(n log n)O(n log n)O(n)Split → sort → merge
Quick SortO(n log n)O(n log n)O(n²)O(log n) average recursionPartition around a pivot
Bubble SortO(n)*O(n²)O(n²)O(1)Swap adjacent inversions
Selection SortO(n²)O(n²)O(n²)O(1)Repeatedly select the minimum

* Bubble sort has O(n) best-case only when implemented with an early-exit check. In-place quicksort typically uses O(log n) recursion space on average, while the simple Python version that constructs separate left/right lists uses O(n) additional memory.