Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create the maze Get a pointer to the start. Make another pointer for a Cell Make a stack Push the start on the stack Draw
Create the maze Get a pointer to the start. Make another pointer for a Cell Make a stack Push the start on the stack Draw the maze Start the two counters (total steps, steps in path) While the stack is not empty Get a pointer to the cell on top of the stack (current cell) If it' s the end, were done Update counters Update symbol to X Break out of loop Update the current cell's symbol to o Draw the maze Get a pointer to a neighbouring cell If the neighbour exists Update counters Update current cell's symbol to o Push the new cell on the stack If there are no valid neighbours, we backtrack Update counters Set symbol to . Pop the cell off the stack Make the program sleep a so it prints nicely (I did 250ms) Print out the counters Draw the maze one final tie Delete things Create the maze Get a pointer to the start. Make another pointer for a Cell Make a stack Push the start on the stack Draw the maze Start the two counters (total steps, steps in path) While the stack is not empty Get a pointer to the cell on top of the stack (current cell) If it' s the end, were done Update counters Update symbol to X Break out of loop Update the current cell's symbol to o Draw the maze Get a pointer to a neighbouring cell If the neighbour exists Update counters Update current cell's symbol to o Push the new cell on the stack If there are no valid neighbours, we backtrack Update counters Set symbol to . Pop the cell off the stack Make the program sleep a so it prints nicely (I did 250ms) Print out the counters Draw the maze one final tie Delete things
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started