Algorithm Visualizer

Visualize sorting algorithms (Bubble, Merge, Quick Sort, and more) with animated bar charts.

Comparisons: 0Swaps / Writes: 0Frame: 1 / 0
UnsortedComparingSwappingPivotSorted

Bubble SortComplexity

BestAverageWorstSpaceStable
O(n)O(n²)O(n²)O(1)Yes

All Algorithms — Quick Reference

AlgorithmBestAverageWorstSpaceStable
Bubble SortO(n)O(n²)O(n²)O(1)Yes
Selection SortO(n²)O(n²)O(n²)O(1)No
Insertion SortO(n)O(n²)O(n²)O(1)Yes
Merge SortO(n log n)O(n log n)O(n log n)O(n)Yes
Quick SortO(n log n)O(n log n)O(n²)O(log n)No
Heap SortO(n log n)O(n log n)O(n log n)O(1)No

About Algorithm Visualizer

Watch sorting algorithms come to life with animated bar-chart visualizations. Choose from Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quick Sort, and Heap Sort. Control array size, animation speed, and array type (random, nearly sorted, reversed, few unique values). Step through frames one at a time or let it play automatically. View live comparison/swap counters and a full time/space complexity reference table.

How to Use

  1. 1Select an algorithm from the dropdown.
  2. 2Choose an array type and adjust the size and speed sliders.
  3. 3Click Play to start the animation, or Step to advance one frame at a time.
  4. 4Watch the bars animate — colors indicate the current operation.
  5. 5View live comparisons and swaps in the stats bar above the chart.
  6. 6Check the complexity tables below for time and space complexity details.

Frequently Asked Questions

Which algorithms are supported?
Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quick Sort, and Heap Sort.
What do the bar colors mean?
Indigo = unsorted, Yellow = being compared, Red = being swapped, Orange = pivot element, Emerald/Green = sorted.
Can I step through frame by frame?
Yes. Click the Step button to advance one animation frame at a time without auto-playing.
What is the Speed slider controlling?
The delay between animation frames. Higher speed = shorter delay, so the sort completes faster.
What is the Array type setting?
"Random" shuffles elements randomly. "Nearly Sorted" has a few out-of-place elements. "Reversed" is in descending order. "Few Unique" uses only 5 distinct values — good for seeing how algorithms handle duplicates.