Question: 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 stack_maze(maze):
"""
Solves a maze using Depth-First search.
Use: path = stack_maze (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 'x'(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
t07.py.
See Stacks - Solving a Maze
This maze can be represented by a Python dictionary:
maze -{'Start': ['A'],'A': ['B','C'],'B': [],'C':['D','E'],
'D': [],'E': ['F','X'],'F':['G','H'],'G':[],'H':[]
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
 Write and test the following function that uses a Stack: def

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!