Skip to main content

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(nlogโกn)O(n \log n) average, O(n2)O(n^2) worst case
Space Complexity: O(logโกn)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(nlogโกn)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(logโกn)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.