Sorting Algorithm Visualizer

- | 0 comparisons | 80 elements
Unsorted Comparing Swapping Sorted

About this visualizer

Four classic comparison-based sorting algorithms, run on the same shuffled array so their behavior is directly comparable. Merge Sort splits the array in half recursively and merges the sorted halves back together — always O(n log n), stable, but needs auxiliary memory. Quick Sort partitions around a pivot and recurses on each side — fast in practice and in-place, but its worst case degrades to O(n²) on already-sorted or adversarial input.

Heap Sort builds a binary max-heap from the array, then repeatedly extracts the maximum — guaranteed O(n log n) with no extra memory, at the cost of worse cache locality than Merge or Quick Sort. Shell Sort is an extension of insertion sort that compares elements a decreasing "gap" apart, moving values closer to their final position early so the final full pass is nearly free.

Each run records the actual comparison and swap operations as they happen, then replays them against the canvas so the highlighted colors (comparing, swapping, sorted) reflect the algorithm's real behavior rather than a scripted animation.

← Back to Simulations