Developer

This experience deserves a bigger screen

The DSA Visualizer is designed for deep focus,
side-by-side code, and real-time execution insight.

On small screens, that level of clarity can't be preserved.

Open on a tablet (landscape) or desktop for the intended experience.

Desktop experience preview

Bubble SortStep-by-Step Visualization

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.

Problem Statement

Given an array of integers, sort the array in ascending order using the Bubble Sort algorithm.

Approach

We loop through the array n-1 times. In each iteration, we swap adjacent elements if they are out of order. This "bubbles" the largest unsorted element to the end. We repeat until no swaps are needed.

Time & Space Complexity

Time complexity is O(n^2) in the average and worst cases. Space complexity is O(1).

Interactive Visualization

Loading Interactive Visualizer...

Click "Play" or use arrow keys to step through the execution.