Beruflich Dokumente
Kultur Dokumente
CS 106B
Handout #19
January 25, 2013
Recursive Backtracking
Solving a Maze
Recursive Backtracking
Eric Roberts
CS 106B
January 25, 2013
The code for the maze program uses enum to define a new
type consisting of the four compass points, as follows:
enum Direction {
NORTH, EAST, SOUTH, WEST
};
x
x
x
x
x
return false;
}
start
(5,
3)
(4, 3)
x
x
x
x
x
dir
WEST
5
5
5
3
3
7
7
5
1
1
3
3
3
7
5
1
1
1
2
3
7
7
5
5
2
2
2
3
3
4
5
5
2
2
4
3
4
4
4
4
4
4
3
The P = NP Question