About this tool
Watch common algorithms execute step by step with animated visualizations of Binary Search, Linear Search, Bubble Sort, and more.
The Algorithm Visualizer steps through a comparison sort on your own array, drawing every comparison and swap as a bar chart you can play, pause, scrub and rewind. Type up to 16 numbers or generate a random set, and it builds the full list of steps up front — highlighting the two indices being compared in amber, the elements already in their final position in green, and running counters for comparisons and swaps. Alongside it sits a browsable catalogue of twelve classic algorithms with their Big-O complexities, and a merge-sort divide-and-merge walkthrough with the Python and JavaScript source.
Open Algorithm Visualizer on AltFTool — it loads instantly in your browser.
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.
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.
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.
Steps are precomputed, so the slider moves backwards as freely as forwards and you can sit on one comparison.
Comparisons, swaps and the current step index update at every frame, so the O(n²) growth is a number you can read.
Paste your own array — including deliberately worst-case or already-sorted input — and see what it costs.
O(n²) in the average and worst case, because each of n passes compares up to n elements. On 7 values that is 21 comparisons; on 16 values it is 120. The visualizer's comparison counter makes this quadratic growth visible directly.
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.
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.
When the data is unsorted, or the list is short enough that sorting it first costs more than scanning it. Linear search is O(n) but works on any array; binary search is O(log n) but requires the array to be sorted first, which is at best O(n log n) if it is not already.