R0KernelPath
roadmap/sandbox

The Sandbox

Reading is not understanding. Tinker here — single-step an algorithm, run toy assembly on a CPU, flip bits, fault a page, train a tiny model — until the concepts feel obvious. Everything runs entirely in your browser, no backend.

Algorithm Visualizer

Code + Visualization · 8 categories

Watch 30 classic algorithms run line by line — the executing source and a plain-English explanation sit right beside the live data.

Pick an algorithm. The code runs step by step — the highlighted line and the note above it tell you exactly what is happening, while the panel on the right shows the data move. Use play, step, or drag the scrubber.

Sorting
Searching
Array
Graph
Tree
Dynamic Programming
Recursion
Math

Bubble Sort O(n²)

Sorting

Swap adjacent out-of-order pairs; the largest value bubbles to the end each pass.

line 1Goal: sort ascending by repeatedly swapping adjacent out-of-order pairs.
source
1function bubbleSort(a) {
2 for (let i = 0; i < a.length - 1; i++) {
3 for (let j = 0; j < a.length - 1 - i; j++) {
4 if (a[j] > a[j + 1]) {
5 [a[j], a[j + 1]] = [a[j + 1], a[j]]; // swap
6 }
7 }
8 // largest unsorted value has bubbled to the end
9 }
10 return a;
11}
5
0
2
1
8
2
1
3
9
4
3
5
step 1 / 49

17 interactive tools, all client-side. Found a bug or want another tool? The whole sandbox is open source.