Interactive Educational Academy

Developer Code Academy

Master essential programming concepts, data structures, and CSS mechanics with interactive, live-executing simulations.

Concept Matrix

Bubble Sort Visualizer

An interactive simulation demonstrating how bubble sort iteratively swaps adjacent elements to sort an array. Ideal for learning computational complexity.

Live Simulator
45
22
89
12
67
34
50
STEP 1 / 0
SPEED CONTROL500MS
typescript schema
function bubbleSort(arr: number[]): number[] {
    const n = arr.length;
    let swapped: boolean;
    for (let i = 0; i < n - 1; i++) {
        swapped = false;
        for (let j = 0; j < n - i - 1; j++) {
            if (arr[j] > arr[j + 1]) {
                // Swap elements
                const temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
                swapped = true;
            }
        }
        if (!swapped) break;
    }
    return arr;
}