Skip to main content
Preparing workspace

Algorithm Visualizer

Watch bubble, selection, insertion, merge, quick and heap sort, plus linear and binary search, run on your own numbers. Pause, scrub and count swaps.

Still loading. If the tool doesn’t appear, reload this page.

About this tool

Algorithm Visualizer

Watch common algorithms execute step by step with animated visualizations of Binary Search, Linear Search, Bubble Sort, and more.

The Algorithm Visualizer animates six sorting algorithms (bubble, selection, insertion, merge, quick and heap sort) and two searches (linear and binary) on your own array of up to 16 numbers. Every comparison and swap is drawn as bars you can play, pause, scrub and rewind, with live counters for comparisons and swaps.

How to use Algorithm Visualizer

  1. Press Start Visualizing to jump to the workspace, or Explore Algorithms to browse the catalogue cards - narrow them with the category chips (Sorting, Searching, Graph, Dynamic Programming) or the Search algorithms box, and each card shows its complexity, such as O(n log n) for Merge Sort.

  2. Under Custom Input, type comma-separated numbers like 38, 27, 43, 3, 9, 82, 10 and press Visualize (only the first 16 are used), or press Random after setting Size to 5, 7, 10, 12 or 16.

  3. Watch the bar chart step through the bubble-sort pass - amber bars are the pair being compared, green bars are already in place - using the play and pause button, the skip arrows and the scrub slider, while the Comparisons, Swaps, Steps and Time counters update underneath.

Why use Algorithm Visualizer

  • Scrub, don't just watch

    Steps are precomputed, so the slider moves backwards as freely as forwards and you can sit on one comparison.

  • Counts as well as colours

    Comparisons, swaps and the current step index update at every frame, so the O(n²) growth is a number you can read.

  • Your data, not a canned demo

    Paste your own array — including deliberately worst-case or already-sorted input — and see what it costs.

Common use cases

  • You are revising for a data-structures exam and want to watch why a nearly-sorted array still costs a full pass of comparisons
  • You are teaching a first-year class and need a chart you can pause mid-comparison and point at, rather than a finished animation
  • You want to compare the comparison count for the same 7 values sorted by hand versus by the algorithm, to check your trace was right

Frequently asked questions

Which algorithms can I animate?

Bubble, selection, insertion, merge, quick and heap sort, plus linear search and binary search (binary search sorts a copy of your array first). BFS, DFS, Dijkstra and knapsack appear in the catalogue with their complexities but are not animated.

Link to answer
What is the time complexity of bubble sort?

O(n²) in the average and worst case, because it makes up to n − 1 passes and compares neighbouring pairs on each one. A full run on 7 values makes at most 21 comparisons; on 16 values, at most 120. The visualizer's comparison counter makes this quadratic growth visible directly.

Link to answer
Why is merge sort faster than bubble sort?

Merge sort is O(n log n) in the best, average and worst case, while bubble sort is O(n²). Splitting the array in half repeatedly gives log n levels of merging, each doing n work, instead of comparing every pair. The trade-off is O(n) extra space for the merge buffers, where bubble sort sorts in place.

Link to answer
How many numbers can I visualize at once?

Up to 16. Input is split on commas or whitespace, non-numeric tokens are dropped, and anything past the sixteenth value is ignored — past that the bars get too thin to read and the step count grows quadratically.

Link to answer
When would you use linear search instead of binary search?Link to answer
What else should I know about this tool?

Steps are built up front, highlighting the indices being compared and the elements already in their final position. Alongside it sits a catalogue of twelve classic algorithms with their Big-O complexities (BFS, DFS, Dijkstra and knapsack are listed for reference but not animated), and a merge sort walkthrough with Python and JavaScript source.

Link to answer