CSE221 · Algorithms

DFS Simulator

Build your own graph, then follow the stack as depth-first search dives deep and backtracks.

ABCDEFGH

Start at A: push it onto the stack.

step 1 of 22
expanding nowinspectingin frontierdone / in treeuntouched

Depth First Search

Follows one path as deep as it goes using a LIFO stack, then backtracks to the last node with an unexplored neighbour.

Time
O(V + E)

Stack (LIFO)

A

Highlighted entry comes out next.

Build your graph

—

Edges (11)

  • A — B
  • A — D
  • B — C
  • B — E
  • C — F
  • D — E
  • D — G
  • E — F
  • E — G
  • F — H
  • G — H
Start node

← → to step, or use the buttons above.