Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write and test the following function that uses a Stack: def stack _ maze ( maze ) : Solves a maze using
Write and test the following function that uses a Stack:
def stackmazemaze:
Solves a maze using DepthFirst search.
Use: path stackmaze maze
Parameters:
maze dictionary of points in a maze, where each point
represents a corridor end or a branch. Dictionary
keys are the name of the point followed by a list of
branches, if any. First point is named 'start', exit
is named dict
Returns:
path list of points visited before the exit is reached,
None if there is no exit list of str
Add the function to a PyDev module named functions. py Test it from
tpy
See Stacks Solving a Maze
This maze can be represented by a Python dictionary:
maze Start: AA: BCB: C:DE
: : :::
Each entry in these Python dictionaries consists of two parts:
ker: value
so for the sample maze, it's 'Start' entry has key: 'Start' and value: A
Since dictionaries use a key rather than an index, to extract a value from a dictionary use the syntax:
value maze key
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