|
Solving a Maze Object - DFS Versionbool solve () { clear conStack; unset visited flags in all maze cells; set visited flag for start cell; push start onto conStack; while (conStack is not empty) { if (top cell has unvisited neighbor N) { set N's visited flag; push address of N onto the conStack; if N is the goal cell, return true; // note early return } pop the conStack; } return false; } |
|