मुख्य कंटेंट तक स्किप करें

Interactive Algorithm Visualizer

knoxiboy
EditReport

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

ControlDescription
▶ PlayRun the animation continuously
⏸ PauseStop at the current step
⏭ Step FwdAdvance one step
⏮ Step BackRevert one step
Array SizeResize and regenerate a random array
SpeedControl milliseconds per animation frame

Color Legend

ColorMeaning
🔵 BlueDefault / unsorted element
🟡 YellowElements currently being compared
🔴 RedElements being swapped
🟢 GreenElements confirmed in final sorted position
🟣 PurpleCurrent binary search range
🟩 EmeraldFound target element

Live Sandbox

🧮 Algorithm Visualizer — Bubble Sort

45
12
89
34
67
23
90
11
Default Comparing Swapping Sorted

Algorithms Included

Bubble Sort

Time Complexity: O(n2)O(n^2) average and worst case, O(n)O(n) best case (already sorted)
Space Complexity: O(1)O(1) — 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]):

PassStepComparisonSwap?Array State
11[4, 3][3, 4, 2, 1]
12[4, 2][3, 2, 4, 1]
13[4, 1][3, 2, 1, 4]
21[3, 2][2, 3, 1, 4]
22[3, 1][2, 1, 3, 4]
31[2, 1][1, 2, 3, 4]

Quick Sort

Time Complexity: O(nlogn)O(n \log n) average, O(n2)O(n^2) worst case
Space Complexity: O(logn)O(\log n) 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: O(nlogn)O(n \log n) — guaranteed
Space Complexity: O(n)O(n) auxiliary

Divides the array into halves, recursively sorts each half, then merges the sorted halves in linear time.


Time Complexity: O(logn)O(\log n) — requires sorted input
Space Complexity: O(1)O(1)

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.

Track Your Progress

Done with this topic? Mark it as complete to track your progress.