Question: PLEASE COMPLETE IN C++ Problem 2 (maze.cpp) Given the starting point in a maze, you are to find and mark a path out of the
PLEASE COMPLETE IN C++
Problem 2 (maze.cpp)
Given the starting point in a maze, you are to find and mark a path out of the maze is represented by a 20x20 array of 1s(representing hedges) and 0s(representing the foot-paths). There is only one exit from the maze(represented by E). You may move vertically or horizontally in any direction that contains a 0; you may not move into a square with a 1. If you move into the square with an E, you have exited the maze. If you are in a square with 1s on three sides, you must go back the way you came and try another path. You may not move diagonally.
For this program, a stack class should be used.
Here is a summary of the algorithm:
1. At the beginning square, we will examine the four adjacent squares and push onto the move stack the ones with a 0 or E in them.
2. In order to move, pop one square from the stack (Stack1). If the stack is empty (when this happens it means that you are surrounded by 1s and/or +s), you are trapped. Mark the square we are in as having been visited by putting a + in the square.
3. Get the next move from the stack and make the square whose coordinates have just been popped the current square.
4. Repeat the process until you either reach the exit point or try to backtrack and the stack 5. Note that the above algorithm does not explain how one determines and marks the path to the exit from the starting point.
PLEASE COMPLETE IN C++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
