About this tool
The Algorithm Arena turns complexity theory into something you can watch. Eight sorting algorithms — QuickSort in both Lomuto and Hoare flavors, MergeSort, HeapSort, RadixSort, InsertionSort, BubbleSort and a deliberately bounded BogoSort — run on one seeded input while every comparison, swap and write is recorded, so you can play, pause, scrub and single-step the exact execution. Race mode puts two or four algorithms side by side on identical data: the lanes finish with different op counts, and the trophy goes to the fewest operations.
The pathfinding lab pairs six classics — BFS, DFS, Dijkstra, A* with Manhattan or Euclidean heuristics, and Greedy Best-First — with three seeded perfect-maze generators (Recursive Backtracker, randomized Kruskal, randomized Prim). Watch the frontier ripple out, see exactly where DFS wastes effort compared to A*, and read the final path cost and visited-cell count for each run.
The data-structure panel records full snapshots at every operation, so BST inserts, AVL rebalancing rotations, Red-Black recolorings, B-Tree node splits, heap sift-downs and trie prefixes can be replayed forward and backward with the active node highlighted and each step explained in plain language.
Every algorithm ships with a line-highlighted reference implementation in JavaScript, Python, Go and C++ — the line currently executing lights up as the engine steps — plus a Big-O table you can export as Markdown, and the whole catalog as JSON. Sound can be enabled so compared values play as pitch (sonification) through the same audio engine that powers the synth tools.
All traces are computed locally in a Web Worker (with an inline fallback): nothing is uploaded, and a 64-element race replays smoothly because the heavy recording happened off the main thread.
How to use this tool
Pick your arena
Choose the Sorting Arena, Pathfinding or Data Structures tab — each is a self-contained lab with its own controls.
Race algorithms
In sorting, toggle Single / Race 2 / Race 4, pick any combination of algorithms, set the size and seed, and press play. The lane with the fewest ops wins.
Walk a maze
In pathfinding, choose the algorithm and maze generator, regenerate for a new layout, then step or scrub through frontier, visits and the final path.
Replay tree operations
Enter keys (or words for a trie), press Run operations, and step through inserts, rotations and recolorings with the tree redrawn at every step.
Read code and complexity
The highlighted source panel follows execution line by line in JavaScript, Python, Go or C++, and the complexity table summarizes best/average/worst/space for every algorithm.
Use cases
Interview prep with receipts
Explain a rotation or a partition scheme while stepping the engine — the op log and highlighted code line back up every claim.
Choosing between algorithms with data, not vibes
Race your real shortlist on the size class you ship (8 vs 64 elements flips the InsertionSort vs MergeSort answer) and read the op counts.
Teaching CS fundamentals
Sonification plus lane races make the O(n log n) vs O(n²) gap something students feel rather than memorize.
Generating teaching material
Export the complexity table as Markdown for course notes, or the four-language catalog JSON for exercises and graders.
Common mistakes
Mistake:Reading op count as wall-clock time
Fix:Ops are engine steps, not seconds — compare algorithms within a language and a size class, not across them; real runtimes depend on memory layout and constants.
Mistake:Treating race winners as universal
Fix:The champion depends on input: re-run with a new seed and different sizes before concluding anything — QuickSort and InsertionSort swap places at small n.
Mistake:Expecting DFS to find the shortest path
Fix:Only BFS, Dijkstra and A* (with an admissible heuristic) guarantee optimality on these grids; DFS finds a path, not the path.
Mistake:Confusing the Euclidean A* variant as 'better'
Fix:Straight-line distance underestimates grid distance, so it stays optimal but usually expands more cells — compare the visited counts.
Frequently asked questions
How does the race mode decide the winner?
All lanes run on the exact same seeded input, and each algorithm records every comparison, swap and write as an operation. The trophy goes to the fewest total operations, shown per lane alongside comparison/swap/write counts. Operations measure engine work, not wall-clock milliseconds — constants differ per language and machine, but op counts make the asymptotic story visible.
Why does QuickSort lose to MergeSort on sorted input?
The Lomuto partition takes the last element as its pivot. On already-sorted (or reverse-sorted) data every split is maximally unbalanced (0 / n−1), which degrades QuickSort to O(n²). MergeSort always splits in half, so its O(n log n) holds regardless of input. The Hoare variant and randomized pivots mitigate this — race all three to see it.
Which pathfinding algorithm should I use?
On unweighted grids: BFS is the simple optimal answer. Dijkstra generalizes it to weighted edges. A* with a Manhattan heuristic is optimal on 4-neighbour grids and usually visits far fewer cells; the Euclidean variant stays admissible but expands more. Greedy Best-First is fastest but not optimal, and DFS only promises a path, not the shortest one.
What does the sonification actually play?
Each comparison maps the compared value to pitch (low values low, high values high) through the shared Web Audio engine — the same one the synth tools use. Listening to a sort run gives you a feel for its access pattern: BubbleSort's sweeps sound like rising arpeggios, QuickSort's partitioning jumps between registers. Audio needs a click to start (browser autoplay policy) and can be toggled off any time.
Are the trees real implementations?
Yes — AVL uses height bookkeeping with LL/RR/LR/RL rotations, Red-Black follows the CLRS insert fixup (recoloring and rotations, with invariant checks enforced by the test suite: black root, no red-red edges, uniform black height), the B-Tree is order 4 (2-3-4) with median promotion on overflow, and heaps sift down from the classic Floyd build. Duplicates are ignored for search trees, as in most textbook treatments.
Can I trust the code snippets when porting?
The JavaScript, Python, Go and C++ snippets are line-aligned reference implementations that mirror the traced engine — the highlight follows the same statement in every language. They favor clarity over micro-optimization (e.g. recursive quicksort, not iterative with explicit stacks), so treat them as the canonical version to verify against, not as a tuned production library.
Is the BogoSort real?
It shuffles until sorted, exactly as advertised — but bounded to 40 shuffles so it can never run away. When it gives up, the trace says so. It exists because watching it 'work' is the fastest way to appreciate why O(n·n!) is a joke, not a strategy.
Does anything leave my browser?
No. Traces are computed in a Web Worker on your device (with an inline fallback where Workers are unavailable), mazes are seeded locally, and the only persistence is your own inputs in localStorage. There is no backend call in any tab.
Related guides
Split-Brain Is a Math Problem: Quorums, Circuit Breakers and Chaos Engineering, Simulated
Why 'majority of replicas' is the entire safety argument behind Raft, how a circuit breaker's three states stop one slow dependency from taking down everything upstream, and what happens when you partition a database on purpose.
Subtractive Synthesis in Ten Minutes: What Every Slider Actually Does
Oscillator, ADSR, filter, LFO, effects — the entire vocabulary of the classic synth, explained the way that finally makes it stick: by watching the FFT while you turn the knob.
Rule 110, the Glider Gun and Why Cellular Automata Keep Winning
A single black cell plus one rule byte can produce chaos, self-similarity and even universal computation. A tour of the automata that taught computer science — Conway's Life, Wireworld circuits, Langton's Ant and Wolfram's Rule 110 — and why stepping them beats memorizing their properties.
Sorting Races, Maze Walkers and Self-Balancing Trees: Learning Algorithms by Watching Them Lose
Reading that QuickSort degrades to O(n²) on sorted input is one thing; racing it against MergeSort on the same data and watching it flail is another. How algorithm visualizers — with step replay, sonification and line-highlighted code — change how engineers internalize complexity.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
AI Function Calling Schema Generator
Generate function calling JSON schemas from TypeScript interfaces
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML
Apache Config Generator
Build an Apache 2.4 VirtualHost — ServerName, DocumentRoot, Directory, aliases, and optional SSL