CS Visualizations

Algorithm Visualizations

Step through sorting and searching algorithms one operation at a time. Use Auto to watch them run, or Step to go at your own pace.

Bubble SortO(n²)

Repeatedly swaps adjacent elements that are out of order. Simple to understand, slow in practice.

Launch →
Selection SortO(n²)

Finds the minimum unsorted element and moves it into place, one pass at a time.

Launch →
Insertion SortO(n²)

Builds a sorted region left to right, inserting each new element into its correct position.

Launch →
Merge SortO(n log n)

Divides the array in half recursively, then merges sorted halves back together. Guaranteed O(n log n).

Launch →
Quick SortO(n log n) avg

Picks a pivot, partitions elements around it, then recurses. Fast in practice; O(n²) worst case.

Launch →
Bogo SortO((n+1)!) avg

Shuffles the array randomly and checks if it's sorted. Repeats until it gets lucky. Not recommended.

Launch →
Miracle SortO(∞)

Checks repeatedly if the array has spontaneously sorted itself. Relies entirely on cosmic intervention.

Launch →
Linear SearchO(n)

Checks each element one by one from left to right. Works on any array — sorted or not.

Launch →
Binary SearchO(log n)

Halves the search space each step by comparing against the midpoint. Requires a sorted array.

Launch →
Bogo SearchO(n × ?)

Picks a random index and checks if it's the target. Repeats until it accidentally succeeds.

Launch →