Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Maze generation algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Iterative implementation (with stack) ==== A disadvantage of the first approach is a large depth of [[recursion]] β in the worst case, the routine may need to recur on every cell of the area being processed, which may exceed the maximum recursion stack depth in many environments. As a solution, the same backtracking method can be implemented with an explicit [[stack (abstract data type)|stack]], which is usually allowed to grow much bigger with no harm. # Choose the initial cell, mark it as visited and push it to the stack # While the stack is not empty ## Pop a cell from the stack and make it a current cell ## If the current cell has any neighbours which have not been visited ### Push the current cell to the stack ### Choose one of the unvisited neighbours ### Remove the wall between the current cell and the chosen cell ### Mark the chosen cell as visited and push it to the stack
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)