ToolBunny LogoToolBunny
Back to Homepage
Algorithm Visualizer

Watch sorting algorithms in action.

About This Tool

The Algorithm Visualizer is an educational tool designed to help developers, students, and enthusiasts understand how different sorting algorithms work. By representing an array of numbers as bars of varying heights, this tool animates the sorting process, showing the step-by-step comparisons and swaps that each algorithm performs. It's a great way to see the efficiency and logic of various sorting methods in action.

Available Algorithms:

Bubble Sort
The simplest sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.
Selection Sort
This algorithm divides the input list into two parts: a sorted sublist of items which is built up from left to right and a sublist of the remaining unsorted items. It proceeds by finding the smallest element from the unsorted sublist and swapping it with the leftmost unsorted element.
Insertion Sort
A simple sorting algorithm that builds the final sorted array one item at a time. It iterates through an input array and removes one element per iteration, finds the place the element belongs in the sorted list, and inserts it there.
Merge Sort
A highly efficient, divide-and-conquer algorithm. It works by recursively dividing the unsorted list into n sub-lists, each containing one element, and then repeatedly merging sub-lists to produce new sorted sub-lists until there is only one sub-list remaining.
Quick Sort
Another efficient, divide-and-conquer algorithm. It works by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. The sub-arrays are then sorted recursively.
How to Use
  1. Select a sorting algorithm from the dropdown menu (e.g., "Bubble Sort").
  2. Use the "Array Size" slider to determine how many items will be in the array to sort.
  3. Click "Generate New Array" to create a new random set of numbers to visualize.
  4. Use the "Speed" slider to control the animation speed.
  5. Click the "Sort" button to start the visualization. The bars will change color to indicate which elements are being compared or swapped.
  6. You can pause, resume, or reset the visualization at any time.