All Tools
Sorting Algorithm Visualizer
Watch five classic sorting algorithms work step by step. Control speed, array size, and initial arrangement. Bars turn yellow during comparisons, red during swaps, and green when sorted.
Controls
Bubble Sort
Step: 0/-1Comparisons: 0Swaps: 0
DefaultComparingSwappingSorted
Reference Guide
Bubble Sort - O(n^2)
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. Simple but slow for large arrays.
Selection Sort - O(n^2)
Finds the minimum element from the unsorted part and puts it at the beginning. Always makes O(n^2) comparisons but at most O(n) swaps.
Merge Sort - O(n log n)
Divides the array in half, sorts each half recursively, then merges the sorted halves. Guaranteed O(n log n) but requires extra memory.
Quick Sort - O(n log n) avg
Picks a pivot element and partitions the array around it. Average case O(n log n), worst case O(n^2), but usually the fastest in practice.