Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Projects › Intermediate

Pathfinding Visualizer

Draw walls on a grid and watch BFS, DFS, Dijkstra and A* find the path step by step — DSA you can show off.

Level: Intermediate · Time: 1 week · Tech stack: React, BFS, Dijkstra, A*

Features to build

What you will learn

Step-by-step guide

1. Grid as a graph

Each cell is a node; neighbours are up/down/left/right that aren't walls.

2. Record, then animate

Run the algorithm instantly and record the order cells were visited; then animate that list with setTimeout. This keeps the algorithm code clean.

function bfs(grid, start, end) {
  const order = [], prev = new Map(), q = [start], seen = new Set([key(start)]);
  while (q.length) {
    const cur = q.shift(); order.push(cur);
    if (same(cur, end)) break;
    for (const n of neighbours(grid, cur)) if (!seen.has(key(n))) { seen.add(key(n)); prev.set(key(n), cur); q.push(n); }
  }
  return { order, path: buildPath(prev, end) };
}

3. Dijkstra and A*

Use a min-heap keyed by distance (Dijkstra) or distance + Manhattan heuristic (A*). Show how A* visits far fewer cells.

4. Performance

Update cells with CSS classes via refs during animation instead of re-rendering the whole grid on every step.

5. Maze generation

Recursive backtracking: carve passages from a start cell, visiting neighbours in random order.

6. Explain it

Add a sidebar explaining each algorithm's guarantees: BFS shortest (unweighted), DFS not shortest, Dijkstra shortest (weights ≥ 0), A* shortest with an admissible heuristic.

Level it up

On your resume

Learn on Codify