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.