Interactive Algorithm Visualizer
Interactive Algorithm Visualizer
Explore sorting and searching algorithms visually. Use Play, Pause, Step Forward, and Step Backward to trace each comparison and swap at your own pace. Adjust the array size and animation speed with the sliders.
Controls
| Control | Description |
|---|---|
| ▶ Play | Run the animation continuously |
| ⏸ Pause | Stop at the current step |
| ⏭ Step Fwd | Advance one step |
| ⏮ Step Back | Revert one step |
| Array Size | Resize and regenerate a random array |
| Speed | Control milliseconds per animation frame |
Color Legend
| Color | Meaning |
|---|---|
| 🔵 Blue | Default / unsorted element |
| 🟡 Yellow | Elements currently being compared |
| 🔴 Red | Elements being swapped |
| 🟢 Green | Elements confirmed in final sorted position |
| 🟣 Purple | Current binary search range |
| 🟩 Emerald | Found target element |
Live Sandbox
🧮 Algorithm Visualizer — Bubble Sort
Algorithms Included
Bubble Sort
Time Complexity: average and worst case, best case (already sorted)
Space Complexity: — in-place
Repeatedly compares adjacent elements and swaps them if out of order. The largest unsorted element "bubbles" to the end with each pass.
Dry Run (array: [4, 3, 2, 1]):
| Pass | Step | Comparison | Swap? | Array State |
|---|---|---|---|---|
| 1 | 1 | [4, 3] | ✅ | [3, 4, 2, 1] |
| 1 | 2 | [4, 2] | ✅ | [3, 2, 4, 1] |
| 1 | 3 | [4, 1] | ✅ | [3, 2, 1, 4] |
| 2 | 1 | [3, 2] | ✅ | [2, 3, 1, 4] |
| 2 | 2 | [3, 1] | ✅ | [2, 1, 3, 4] |
| 3 | 1 | [2, 1] | ✅ | [1, 2, 3, 4] |
Quick Sort
Time Complexity: average, worst case
Space Complexity: average stack depth
Partitions the array around a pivot element. Elements smaller than the pivot go left; larger go right. Recursively sorts sub-arrays.
Merge Sort
Time Complexity: — guaranteed
Space Complexity: auxiliary
Divides the array into halves, recursively sorts each half, then merges the sorted halves in linear time.
Binary Search
Time Complexity: — requires sorted input
Space Complexity:
Repeatedly halves the search range by comparing the target with the middle element. Purple bars indicate the active search window; emerald marks the found element.
Done with this topic? Mark it as complete to track your progress.
Was this page helpful?
Discuss this page
Have a question or spot something confusing in "Interactive Algorithm Visualizer"? Ask below. Backed by GitHub Discussions—maintainers receive system notifications directly.