The maze
S is the start and the flag is the goal. Black blocks are walls, brown cells are mud: entering mud costs 3, entering a plain cell costs 1. DFS ignores the mud too.
Going deep: 4 cells opened
DFS opens the cell on top of the stack, the one added last. That is why it keeps going in one direction and backs up at a dead end. 5 cells wait on the stack.
Going deep: 8 cells opened
DFS opens the cell on top of the stack, the one added last. That is why it keeps going in one direction and backs up at a dead end. 7 cells wait on the stack.
Going deep: 12 cells opened
DFS opens the cell on top of the stack, the one added last. That is why it keeps going in one direction and backs up at a dead end. 6 cells wait on the stack.
Going deep: 16 cells opened
DFS opens the cell on top of the stack, the one added last. That is why it keeps going in one direction and backs up at a dead end. 9 cells wait on the stack.
Going deep: 20 cells opened
DFS opens the cell on top of the stack, the one added last. That is why it keeps going in one direction and backs up at a dead end. 13 cells wait on the stack.
Going deep: 24 cells opened
DFS opens the cell on top of the stack, the one added last. That is why it keeps going in one direction and backs up at a dead end. 15 cells wait on the stack.
A path is found
The goal is reached in 23 steps with cost 23. This may not be the shortest path: DFS stops at the first path it finds. 24 cells were opened.
Why it matters
DFS can explore deep trees with little memory. Puzzle solvers, constraint satisfaction and game trees use its idea of backtracking.