Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help. Notice the requirements in the middle of the problem. I saw some solutions on the Chegg site and I don't think it is

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedPlease help.

Notice the requirements in the middle of the problem.

I saw some solutions on the Chegg site and I don't think it is correct, please answer by your own! Thank you very much!

The 20*20 input file is like this

20 20 + ++++++++++++++++++ + + ++ +++ +++ ++++++ ++ ++ + +++ +++ ++++ + + ++ ++++++ + +++ ++ ++ ++ + + +++ ++++ ++ ++ + + ++++ ++ +++++ + + + +++ +++ + + ++ + +++ ++++++ ++ + +++++ +++ ++ + +++ ++++ ++ ++ + ++++ +++ + +++ +++++++++++ + ++ +++++++ + ++ +++ ++++++++ + ++ ++++++ + + + +++ ++++++ +++ ++++ +++ +++ +++++++++++++ ++++++

I thought 20 20 is for the row and col.

The program should handle up to 22 rows by 76 columns.

TITLE RECURSIVELY FINDING PATHS THROUGH A MAZE INTRODUCTION Recursion is a programming technique in which a function calls itself. This project applies recursion to a new problem, and illustrates the recursive implementation of backtracking DESCRIPTION Design, implement, test, and document a program that calls a recursive function to find a path through a maze. The path will extend from an entrance at the top of the maze to an exit at the bottom. An array of characters represents a maze: blanks represent corridors, and characters represent walls. Indicate the steps along a path with some other character. The program reads a maze from a data file, identifies the path(s) through the maze, and prints out each path. There may be more than one path INPUT The program reads the name of a data file from the terminal. A data file will contain the dimensions of a maze and an array of 's and blanks that represent the maze. This array must be no larger than 22 rows by 76 columns, so that it can be displayed on a standard terminal screen. The entrance to the maze will always be the second position on the top row, which must therefore be bank. The exit must be on the mazes otom row Except ots entrance and exit the entire perimeter of the maze must be "wall there will be no other entrances or exits. OUTPUT The program's output will be the maze with a path through it indicated, one such picture of the maze for each path. Direct output to the terminal. ERRORS The program should recover gracefully if the user enters the name of an input file that does not exist. Otherwise, it may assume that the input is correct, it need not detect any errors. EXAMPLE This is a typical instance of this problem. The input file maze. dat is on the left. Corresponding output might look like the right figure 20 20 A path through the maze: +000000+ ++++0000+++000++++ OTHER REQUIREMENTS Use a recursive function to identify each step of a path through the maze. Your program should be able to handle mazes of any dimensions up to 22 by 76 read the dimensions of each maze from its file. (The example above is 20 by 20.) Test the program with examples that are at least 16 by 16. Note that larger examples are more entertaining HINTS The main program should read a maze from a file into an array and call the recursive function that identifies paths. Include a function that reads a data file and another that prints out the array that represents a maze. The recursive function will call the latter function. Each legal step moves closer to a complete path or a dead end, so that after that step, the problem is smaller. At each position, there are four directions that must be checked for the next step (which will be passed to a recursive procedure call). No more than three of these steps will be possible (the previous step will occupy one adjacent position), but the code must contain four recursive calls in independent if statements The base cases of the recursion occur when the path (the current position) reaches a dead end and no move is possible and when the path reaches the bottom row of the maze/array. In the first case, simply return. In the second case, print the array, which will include the path just completed The maze array will be automatically passed by reference, so that all instances of the path-finding function will be operating on one copy of the array. Thus, the function will have to take back" each move it makes after the corresponding recursive call has returned Blocks of open spaces in a maze will allow many paths and may produce more output than you expect. It's best to avoid them

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

Data Infrastructure For Medical Research In Databases

Authors: Thomas Heinis ,Anastasia Ailamaki

1st Edition

1680833480, 978-1680833485

More Books

Students also viewed these Databases questions