Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program l: Maze Due date: Sunday, 02/17/19 a 11:59pm (Maze Traversal Using Recursive Backtracking The grid of#s and dots (.) in Figure 1 wo-dimensional array

image text in transcribed

Program l: Maze Due date: Sunday, 02/17/19 a 11:59pm (Maze Traversal Using Recursive Backtracking The grid of#s and dots (.) in Figure 1 wo-dimensional array representation of a maze. The #s represent the walls of the maze, and the dots represent locations in the possible paths through the maze. A move can be made only to a location in the array that contains a dot. Write a recursive method (mazeTraversal) to walk through mazes like the one in the Figure. The method should receive as arguments a 12-by-12 character array representing the maze and the current location in the maze (the first time this method i called, the current location should be the entry point of the maze). As mazeTraversal attempts to locate the exit, it should place the character x in each square in the path. There's a simple algorithm for walking through a maze that guarantees finding the exit (assuming there's an exit). If there's no exit, you'll arrive at the starting location again. The algorithm is as follows: From the current location in the maze, try to move one space in any of the possible directions (down, right, up or left). If # # # # . #-# . # . # 9 Figure 1. Two-dimensional array representation of a s possible to the new spot on the maze as the current spot. If it's not possible to go in any direction back up" to a previous location in the maze and try a new direction for that location (this is an example of recursive backtracking). Program the method to display the maze after each move so the user can watch as the maze is solved. The final output of the maze should display only the path needed to solve the maze-if going in a particular direction results in a dead end, the x's going in that direction should not be displayed. [Hint: To display only the final path, it may be helpful to mark off spots that result in a dead end with another character (such as '0').] move in at least one direction, call mazeTraversal recursively, passing Use the java files provided by the instructor. The java file "Maze java" contains a skeleton class definition o use this skeleton to complete the mazeTraversal method. f A Modify the application such that it takes from the user the name of a file containing a 12 x 12 puzzle to solve. Then the application should read the file and find a solution if one exists. The input file must have the following format: the first line of the input file contains two integer numbers separated by a space: row column. Representing the row and column number (index origin = 0) of the entry position to the maze. Then, the maze is given as a 12 by 12 grid of#s and dots

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

What is the difference between systems analysis and systems design?

Answered: 1 week ago