Skip to content

Algorithms

Abhishek Rai A edited this page Jun 21, 2026 · 1 revision

Algorithms

Five classic sorting algorithms, all instrumented to emit a typed Step[] stream from src/lib/algorithms.ts.

Algorithm Best Average Worst Space Stable
Bubble Sort O(n) O(n²) O(n²) O(1)
Selection Sort O(n²) O(n²) O(n²) O(1)
Insertion Sort O(n) O(n²) O(n²) O(1)
Merge Sort O(n log n) O(n log n) O(n log n) O(n)
Quick Sort O(n log n) O(n log n) O(n²) O(log n)

Each step records the exact pointer positions and operation type (compare / swap / overwrite), which is what drives the live pointer chips and captions in the visualizer.

All algorithm logic is pure TypeScript with no dependencies and no side effects, making it easy to test or reuse outside the UI.

Clone this wiki locally