Answered step by step
Verified Expert Solution
Link Copied!

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 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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

2. Are my sources up to date?

Answered: 1 week ago