Bubble Sort Visualization

An interactive demonstration of the bubble sort algorithm

Visual Demonstration

Algorithm Explanation

What is Bubble Sort?

Bubble Sort is an intuitive sorting algorithm that works by repeatedly stepping through the list, comparing adjacent elements and swapping them if they are in the wrong order.

Working Principle

  1. 1 Compare adjacent elements in the array
  2. 2 Swap them if they are in the wrong order
  3. 3 Repeat until no more swaps are needed

Complexity Analysis

Time Complexity: O(n²)
Space Complexity: O(1)
Stability: Stable
Red bars indicate elements being compared, blue bars represent unsorted elements