Question: I am creating a maze using C++ and stacks but i need to create a solver. I have the psudeo code create an empty LocStack

I am creating a maze using C++ and stacks but i need to create a solver. I have the psudeo code

create an empty LocStack object

for ( row&col are 0; while neither row nor col are -1; pop new r and c from the stack)

if current location contains 'F' it is solved! so you return true

set the current location to 'o' to show it has been searched (the current location is amaze[row][col])

push all (possible) adjacent locations (row, col) onto stack:

if neighbor up (amaze[row-1][col]) is not outside or a wall or already done, push row-1, col

if neighbor right (amaze[row][col+1]) is not outside or a wall or already done, push row, col+1

if neighbor down (amaze[row+1][col]) is not outside or a wall or already done, push row+1, col

if neighbor left (amaze[row][col-1]) is not outside or a wall or already done, push row, col-1

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!