Algorithm Visualizer
Free online algorithm visualizer. Watch Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quick Sort, Linear Search, and Binary Search animate step by step. Control playback speed, step through manually, and understand exactly how each algorithm works.
About This Tool
An algorithm visualizer turns abstract computer science concepts into animated bar charts you can watch, pause, and step through at your own pace. This tool covers the most important sorting and searching algorithms every developer should know.
Sorting algorithms rearrange an array of values into a specific order. Bubble Sort repeatedly swaps adjacent elements that are out of order — simple to understand but O(n²) in the average case. Selection Sort finds the minimum element in the unsorted portion on each pass and swaps it into place. Insertion Sort builds a sorted section from left to right, inserting each new element at the correct position — it performs well on nearly sorted data.
Merge Sort uses a divide-and-conquer approach: split the array in half, recursively sort each half, then merge the two sorted halves. It guarantees O(n log n) time at the cost of O(n) extra space. Quick Sort also uses divide-and-conquer but picks a pivot element and partitions the array around it. On average it's O(n log n) and is often faster than Merge Sort in practice due to better cache performance.
Searching algorithms find a target value in an array. Linear Search checks every element from left to right — O(n) time, works on unsorted arrays. Binary Search is much faster at O(log n) but requires a sorted array: it repeatedly halves the search range by comparing the middle element with the target.
Use the speed control to slow down and see every comparison and swap clearly. Use the step button to advance one operation at a time. Generate a new array to see how the algorithm behaves on different inputs. For binary search, the array is automatically sorted before the animation begins.
Frequently Asked Questions
What algorithms does this visualizer support?
It supports 5 sorting algorithms — Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, and Quick Sort — plus 2 searching algorithms: Linear Search and Binary Search.
What do the bar colors mean?
Blue = default. Yellow = elements being compared. Red = elements being swapped or moved. Green = element placed in its final sorted position (or found in a search). Purple = pivot element in Quick Sort. Sky blue = current search range in Binary Search.
How does Binary Search work here?
Binary Search requires a sorted array. When you select Binary Search, the array is automatically sorted before the animation starts. The target value is shown above the chart. The visualizer highlights the active search range in sky blue and the middle element in yellow on each step.
Which sorting algorithm is fastest?
Merge Sort and Quick Sort are both O(n log n) on average — significantly faster than Bubble, Selection, and Insertion Sort which are O(n²). Quick Sort is often fastest in practice for random data, while Merge Sort guarantees O(n log n) even in the worst case.
Is this tool free to use?
Yes, completely free. All animations run in your browser — no data is sent to any server.
Related Tools
Algorithm Visualizer
Free online algorithm visualizer. Watch Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quick Sort, Linear Search, and Binary Search animate step by step. Control playback speed, step through manually, and understand exactly how each algorithm works.