Algorithm Visualizations

Watch algorithms in action with real-time animations. Adjust speed, change inputs, and compare different approaches.

30
50%
Comparisons:0
Swaps:0

Bubble Sort

Best Case
O(n)
Average
O(n²)
Worst Case
O(n²)
Space
O(1)
Stable
Yes
Default
Comparing
Swapping
Sorted
Pivot
Minimum

About the Algorithm Visualizer

Code Visualizer's algorithm visualizer brings sorting, searching, pathfinding, dynamic programming, sliding window, two pointers, and greedy algorithms to life with real-time animations. Watch Bubble Sort swap elements, see Dijkstra's shortest path unfold on a grid, animate the sliding window technique on arrays, or trace recursive call trees for Fibonacci — all step by step.

Sliding Window Technique

Master the sliding window pattern used in coding interviews. Visualize fixed-size windows for maximum sum subarray (Kadane's variant) and variable-size windows for longest substring without repeating characters. See how the window expands and shrinks in real-time.

Two Pointer Technique

Understand the two-pointer approach for sorted arrays and optimization problems. Watch pointers converge in Two Sum, see container boundaries shift in Container With Most Water, and track the slow/fast pointer pattern for removing duplicates.

Greedy Algorithms

See how greedy algorithms make locally optimal choices. Visualize Activity Selection on a timeline, watch Fractional Knapsack fill by value-to-weight ratio, and observe Job Sequencing assign tasks to deadline slots for maximum profit.

Understanding Big O notation becomes intuitive when you can see the difference between O(n²) and O(n log n) play out visually. This visual learning tool doubles as a code debugger for algorithm logic, making it ideal for coding interviews, competitive programming prep, and computer science education. All 10 algorithm categories — Sorting, Searching, Sliding Window, Two Pointers, Pathfinding, Recursion, Dynamic Programming, Greedy, String Matching, and Backtracking — are interactive and animated.