Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

algorithm-visualizer

CI

Interactive visualizations of classic pathfinding and sorting algorithms — built to show the algorithms running, not just describe them. Every algorithm (and the binary-heap priority queue behind Dijkstra/A*) is implemented from scratch in TypeScript, unit-tested, and then animated in a Next.js UI.

Live demo: deploy in one click to Vercel (see below) — or run locally.

What's in it

Pathfinding (draw walls, generate a maze, watch the search expand toward the goal):

Algorithm Data structure Finds shortest path?
Breadth-First Search queue yes (unweighted)
Depth-First Search stack no
Dijkstra binary-heap priority queue yes (weighted)
A* binary-heap + Manhattan heuristic yes (weighted), guided

Sorting (animated bars with live comparison/swap counts): bubble, insertion, selection, quicksort, merge sort, heap sort.

Why it's more than a UI

The interesting code is the tested algorithm core under src/lib/, independent of React:

  • heap.ts — a from-scratch binary min-heap (array-backed complete tree).
  • pathfinding.ts — BFS/DFS share a frontier driver; Dijkstra and A* share a uniform-cost driver that differs only by heuristic (() => 0 vs Manhattan).
  • sorting.ts — six sorts instrumented to emit animation frames + operation counts.
  • maze.ts — recursive-backtracker maze generation (randomized DFS).

These are verified by src/lib/__tests__ and run in CI:

BFS finds the shortest path · Dijkstra & A* agree with BFS on optimal length · A* routes around weighted cells · every sort matches [...a].sort() and never mutates its input · the generated maze is fully connected (BFS reaches every open cell) · the heap pops in sorted order.

Complexity

Algorithm Time Space
BFS / DFS O(V + E) O(V)
Dijkstra (binary heap) O((V + E) log V) O(V)
A* O((V + E) log V), fewer expansions with a good heuristic O(V)
Bubble / Insertion / Selection O(n²) O(1)
Quicksort O(n log n) avg, O(n²) worst O(log n)
Merge sort O(n log n) O(n)
Heap sort O(n log n) O(1)

Run locally

npm install
npm test          # vitest — the algorithm test suite
npm run dev       # http://localhost:3000
npm run build     # production build (typecheck + compile)

Deploy (Vercel)

Import the repo at vercel.com/new — it auto-detects Next.js, needs no env vars, and gives you a live URL. (No backend, no secrets, nothing to abuse.)

Tech

TypeScript · Next.js (App Router) · Vitest. No algorithm libraries — the point is the from-scratch implementations.

About

Interactive pathfinding (BFS/DFS/Dijkstra/A*) and sorting visualizations. From-scratch TypeScript algorithms + binary heap, unit-tested, Next.js UI.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages