Nils Harrison
Front-End Engineer
About MePosts

Animated Sorting Algorithms

This page visualizes six different sorting algorithms working on identical randomly shuffled arrays of 100 elements. Each algorithm demonstrates different approaches to the sorting problem, from the divide-and-conquer strategy of Quicksort and Merge Sort to the simple but inefficient approaches of Bubble Sort and Insertion Sort.

Notice the dramatic differences in the number of operations required. The O(n²) algorithms (Bubble, Insertion, Selection) will take significantly more steps than the O(n log n) algorithms (Quicksort, Merge Sort). Each swap or move operation is captured as a frame in the animation.

Quicksort (Lomuto)

O(n log n) average, O(n²) worst

Quicksort (Hoare)

O(n log n) average, O(n²) worst

Merge Sort

O(n log n) guaranteed

Selection Sort

O(n²) but minimal swaps

Insertion Sort

O(n²) but good for small/sorted data

Bubble Sort

O(n²) educational classic

Algorithm Characteristics:

  • Quicksort: Fast average case, but pivot choice affects performance
  • Merge Sort: Consistent O(n log n), stable, but uses extra memory
  • Selection Sort: Always O(n²) but minimizes swaps
  • Insertion Sort: Efficient for small or nearly sorted arrays
  • Bubble Sort: Simple to understand but inefficient for large data