Interactive Algorithm Learning

Watch Algorithms Sort in Real Time

Step through 7 classic sorting algorithms with color-coded bar charts, call stack displays, and full playback controls. Perfect for learning data structures and algorithms.

Bubble Sort

Comparison

Repeatedly compares adjacent elements and swaps them if out of order, bubbling the largest value to the end each pass.

Best O(n)
Average O(n²)
Worst O(n²)
Space O(1)

Selection Sort

Comparison

Finds the minimum element in the unsorted portion and places it at the beginning, growing the sorted section one element at a time.

Best O(n²)
Average O(n²)
Worst O(n²)
Space O(1)

Insertion Sort

Comparison

Builds a sorted array one element at a time by inserting each new element into its correct position within the already-sorted portion.

Best O(n)
Average O(n²)
Worst O(n²)
Space O(1)

Shell Sort

Comparison

An improved insertion sort that compares elements separated by a shrinking gap, allowing faster long-distance element movement.

Best O(n log n)
Average O(n log² n)
Worst O(n²)
Space O(1)

Merge Sort

Divide & Conquer

Recursively divides the array in half, sorts each half, then merges them back together — guaranteeing O(n log n) performance always.

Best O(n log n)
Average O(n log n)
Worst O(n log n)
Space O(n)

Quick Sort

Divide & Conquer

Picks a pivot element and partitions the array around it, recursively sorting each partition. The fastest in practice on average.

Best O(n log n)
Average O(n log n)
Worst O(n²)
Space O(log n)

Heap Sort

Divide & Conquer

Builds a max-heap from the array, then repeatedly extracts the maximum element and places it at the end to build the sorted result.

Best O(n log n)
Average O(n log n)
Worst O(n log n)
Space O(1)