10.14 a.
In the following pseduocode for MazePath, Move[0:3, 0:1] has been initialized to represent the
4 pairs (1,0), (-1,0), (0,1), (0,-1), which represent the possible displacements for a move to an
adjacent cell in Maze[0:n – 1, 0:n – 1]. Hence, from cell (p,q), a move can be made to the cell
(p + Move[i,0], q + Move[i,1]), i = 0, 1, 2,3 in Maze [0:n – 1, 0:n – 1] so long as a given such
Move[0:3, 0:1] (global array initialized to 4 displacements representing possible
moves in the maze)
Output: Maze[0:n – 1, 0:n – 1], and when a path exists, if Maze[p,q] > 1, it represents the
number of the moves – 2 made to get to the cell [p,q]. When Maze[0,0] = 0, then no path
exists. X[0:n*n – 1] where X[k] contains a move made in kth point in the path.
// good move
k ← k + 1
Maze[x,y] ← k+1
if x = n – 1 .and. y = n – 1 then return endif // found the path
X[k] ← 0