Question: The 5 x 5 maze below represents a sample boulder field. The ' 1 ' values represent boulders and the ' 0 ' values represent

The 5x5 maze below represents a sample boulder field. The '1' values represent boulders and the '0' values represent paths between.
Using the algorithm below, show the resulting path with 'X' characters for the 7x7 maze. Mark backtracking with '#' characters.
Your search will begin at row 0 column 0, represented as coordinates (0,0). You are aiming for row 6, column 6 or (6,6).
***Pseudo Code Algorithm for a Depth First Search ***
Create an empty search queue for positions yet to explore, add the entrance (0,0), to the queue
Create an empty stack to hold the path of coordinates
While the search list is not empty
Remove the next position from the search queue
If it is the exit position, (n-1, n-1),
then a path is found
Otherwise, mark the position as visited (use an 'X'), push the position on the stack,
and add all valid right, down, left, or up neighbor positions to the search queue (in that order)
While the next position in the search queue is not adjacent to the position on the top of the stack, pop the stack and
mark the position as backtracked (use a '#')
If the search queue is empty and the current position is not the goal position, there is no path
------------------------------------------------------
Example 5x5 boulder maze and solution:
01010
00010
01000
01011
01000
5x5 solution:
start---> X 101 #
X X X 1 #
01 X # #
01 X 11
01 X X X ---> goal

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!