Skip to content

Releases: nirbhayagga/stepwise

Stepwise 1.5 — race conditions, frame by frame

Choose a tag to compare

@nirbhayagga nirbhayagga released this 04 Sep 23:11

The Systems section grows a second module: race conditions you can scrub through, one instruction at a time.

Threads & Race Conditions (new module)

  • Simulated threads run the same tiny program against shared memory; a seeded scheduler decides which thread executes its next instruction. A fixed seed means a fixed interleaving — fully deterministic, so it plays, pauses and rewinds like every other Stepwise timeline. A Shuffle interleaving button rolls a new seed.
  • Counter Without a Lock — counter++ is really LOAD / INC / STORE, and the default interleaving is chosen so you watch two of four increments vanish: a thread stores a stale register over a newer value, and the shared counter ends at 2 instead of 4.
  • Counter With a Mutex — the same program with the read–modify–write in a critical section. Threads that arrive while the lock is held show up blocked; nothing is lost, at the price of making that code serial again.
  • Atomic Counter — the increment as one indivisible fetch-and-add: correct with no lock and no blocking.
  • Per-thread cards (iteration, private register, next instruction, ready/blocked/finished), the executed-instruction strip, and metrics for context switches and lost updates. Threads (2–4), increments and seed are all editable.

Amdahl's law

An interactive panel under the visualizer: drag the parallel-fraction slider and see the speedup curve over 1–64 cores flatten against its 1/(1−p) ceiling (dashed), with Gustafson's scaled-workload answer as an optional overlay — and a reminder that the serial part is exactly the critical sections above.

Verification

9 new tests, 143 passing in total. Mutex and atomic variants must land exactly on the expected count across 25 seeds while the racy one loses updates on most of them; mutual exclusion is checked in every frame of 4-thread runs (never two threads past acquire, and the one inside always matches the lock holder); interleavings are reproducible per seed; and the shipped default is required to demonstrate the race, so it can never silently become a boring example.

Stepwise 1.4 — CPU scheduling

Choose a tag to compare

@nirbhayagga nirbhayagga released this 04 Sep 23:11

Stepwise steps into operating systems: a CPU scheduling module, under a new Systems section.

CPU Scheduling (new module)

  • Five policies: First-Come First-Served, Shortest Job First, Shortest Remaining Time First (preemptive), Round Robin with a configurable quantum, and non-preemptive Priority.
  • One frame per clock tick or scheduler decision, so preemptions, arrivals and idle gaps can be stepped through and scrubbed like everything else in Stepwise.
  • The canvas is the classic Gantt strip plus per-process lanes showing each process running, waiting in the ready queue, or not yet arrived — with the live ready queue (in each policy's own order) underneath.
  • Fully editable process table: arrival times, burst times, priorities and quantum, with per-process completion, turnaround and waiting times filling in as the schedule runs, and average waiting / average turnaround / context-switch metrics on top.

Verification

12 new tests, 134 passing in total. Every policy's schedule is checked for the basics (each process runs exactly its burst after its arrival, the CPU never idles while work is ready, the reported averages match an independent recomputation); Round Robin is compared tick-for-tick against a reference simulation; and SRTF's claim to fame is enforced — its average waiting time must beat every other policy on randomized instances.

Stepwise 1.3 — offline PWA, growth analysis

Choose a tag to compare

@nirbhayagga nirbhayagga released this 04 Sep 23:11

Stepwise now works with no network at all — and can measure its own algorithms.

Offline PWA

  • A service worker precaches the entire app, so after one visit it loads and runs fully offline. Install it from the browser and it behaves like a native app (proper 192/512 px and maskable icons included).
  • Inter and JetBrains Mono are now bundled with the app instead of loaded from Google Fonts. Stepwise makes zero third-party requests, and the Content-Security-Policy is now pure 'self'.
  • New deploys are picked up automatically on the next visit.

Growth Analysis (new module)

  • Runs every sorting algorithm across input sizes 8–512 and four input distributions (random, sorted, reversed, few-unique), counts real operations, and plots the curves against each other on a log or linear scale.
  • The empirical order is fitted from the measurements alone — least-squares in log–log space — and reported next to each curve (bubble sort comes out ≈ Θ(n²) with slope n^2.01; merge sort ≈ Θ(n log n)). Compare it with what the complexity card claims.
  • A plain-English primer on O, Ω, Θ and amortized analysis sits below the chart.

Recurrences

  • Complexity cards now show the recurrence relation where one drives the analysis — merge sort reads T(n) = 2T(n/2) + Θ(n) ⇒ Θ(n log n) — Master case 2; quicksort, closest pair, Hanoi, naive Fibonacci, subsets and permutations got theirs too.

Tests: 122 passing, including cross-checks that the growth measurements agree with the visualizer's own metrics and that the empirical classifier recovers n, n log n and n² on stereotypical inputs.

Stepwise 1.2 — Sudoku three ways, recursion call trees

Choose a tag to compare

@nirbhayagga nirbhayagga released this 04 Sep 23:11

Two things this release: Sudoku gets serious, and recursion gets a module of its own. 73 algorithms total.

Sudoku, three ways

The Backtracking module now solves the same puzzle with three engines, so the metrics tell the story directly:

  • Naive backtracking (existing) — first empty cell, digits 1–9, hundreds of steps of trial and error.
  • Constraint propagation + MRV — the Norvig-style engine behind sudoku.nirbhay.dev: 9-bit candidate masks, naked/hidden-single cascades on every elimination, and most-constrained-cell guessing when logic stalls. Solves the easy default with zero guesses; open cells show their live candidate count.
  • Human techniques — no guessing at all: naked and hidden singles for placements, naked pairs/triples, pointing pairs and X-Wings to prune candidates, with each applied technique named and tallied. Stops honestly when the ladder stalls.

Recursion module

Live call trees, one node per invocation, captions filling in as calls return:

  • Naive vs. memoized Fibonacci on the same n — watch 67 calls collapse to 15, with memo hits highlighted; the collapse is dynamic programming.
  • Subsets (2ⁿ leaves) and permutations (n! leaves) — the counting identities drawn.
  • Tower of Hanoi — 2ⁿ−1 moves with peg state tracked per move.
  • Ackermann — nested recursion that outgrows the canvas fast; explosive inputs are refused with an explanation.

All verified in CI: solver outputs cross-checked between engines, call-tree node counts against closed forms, Hanoi move legality simulated, 115 tests.

Stepwise 1.1.1 — polish

Choose a tag to compare

@nirbhayagga nirbhayagga released this 04 Sep 23:11

Polish release.

  • Custom 404 view for unknown routes, with a link back to the visualizer.
  • Per-module browser-tab titles ("Graphs · Stepwise", …) for sane bookmarks and history.
  • Sidebar footer: GitHub, license, author — and an honest "No tracking · no cookies" note.
  • aria-labels on every visualization canvas.

Stepwise 1.1 — five new modules, 65 algorithms

Choose a tag to compare

@nirbhayagga nirbhayagga released this 04 Sep 23:11

Five new modules and 27 new algorithms — 65 total.

New modules

  • String matching — Knuth–Morris–Pratt, Boyer–Moore–Horspool, Rabin–Karp, Z-algorithm, with a sliding pattern row and the precomputed table (failure function, Z array, shift table) shown live.
  • Hash tables — separate chaining, linear probing, quadratic probing, double hashing; collisions, load factor and automatic rehashing, plus search hits/misses.
  • Computational geometry — Graham scan, gift wrapping and closest pair (divide & conquer) on random point sets.
  • Backtracking — N-Queens and a Sudoku solver with constraint-conflict pruning.
  • Number theory — the Sieve of Eratosthenes.

Added to existing modules

  • Sorting: TimSort (Java & JS built-in; Python ≤ 3.10), Powersort (the merge policy behind Python ≥ 3.11's sorted()), bucket sort, bogosort.
  • Pathfinding: bidirectional Dijkstra, Theta* any-angle search.
  • Dynamic programming: Floyd–Warshall with an editable weight matrix and negative-cycle detection.
  • Trees: segment tree (build / range query / point update), trie, Huffman coding — the canvas now renders n-ary nodes and forests.
  • Graphs: Bellman–Ford on generated graphs with negative edges (but provably no negative cycles), Tarjan strongly connected components, Edmonds–Karp max-flow with live flow/capacity edge labels.

Every algorithm is verified in CI against an independent reference (Kosaraju for Tarjan, brute force for closest pair, textbook answers for DP, and so on). 103 tests.

Stepwise 1.0 — scrubbable algorithm visualizer

Choose a tag to compare

@nirbhayagga nirbhayagga released this 04 Sep 23:11

First release of Stepwise, an interactive algorithm visualizer. Every run is recorded as a sequence of immutable frames, so any algorithm can be played, paused, stepped in either direction, and scrubbed on a timeline — with the active pseudocode line, live variables, and step counters shown for every frame.

Live: https://stepwise.nirbhay.dev

Modules

  • Sorting — Bubble, Cocktail shaker, Selection, Insertion, Shell, Merge, Quick, Heap, Counting, Radix (LSD), plus a lockstep side-by-side compare view.
  • Pathfinding — Dijkstra, A*, Jump Point Search, Greedy best-first, BFS, Bidirectional BFS, DFS on a 4- or 8-connected grid with walls and weighted cells; five terrain generators (recursive backtracker, randomised Prim, randomised Kruskal, recursive division, random walls/weights); draw terrain with mouse or touch; compare view on mirrored grids.
  • Dynamic programming — 0/1 Knapsack, Longest Common Subsequence, Edit distance, Coin change, Longest Increasing Subsequence, Matrix-chain multiplication, with labelled tables and dependency highlighting.
  • Binary trees — BST insertion and deletion, AVL, Red–black, binary max-heap (insert and extract-max), and in-/pre-/post-/level-order traversals.
  • Graphs — BFS, DFS with discovery/finish times, Dijkstra, Prim, Kruskal with union–find labels, and Kahn's topological sort on generated planar-looking graphs.
  • Sandbox — write your own algorithm in JavaScript against a small drawing API; runs in a Web Worker so it can always be stopped.

Every algorithm page shows its complexity (best/average/worst, space, properties), a colour legend, and honest step metrics — wall-clock time is deliberately not reported, since it would measure the recorder rather than the algorithm.

Engineering

  • Vue 3 + TypeScript + Vite, fully static, no backend; frames stored as typed arrays for cheap scrubbing on large inputs.
  • Adding an algorithm is one file (metadata + pseudocode + generator) plus one registry entry.
  • Tested: node-side invariant checks for all 38 algorithms (sortedness, optimal-cost agreement, tree/heap/MST invariants, valid topological orders, pseudocode line ranges) and Playwright end-to-end tests including touch/mobile viewports; Lighthouse budgets in CI.
  • Ships as a static site (Cloudflare Workers) and as a container image: docker pull ghcr.io/nirbhayagga/stepwise:1.0.0.
  • Keyboard: Space play/pause, ←/→ step, Home/End jump, R reset.