Question: Java Laboratorv 3: Maze Recursion Java API First, we'll show you a demo of what you are trying to accomplish Download Lab03.zip from ilearn and

Java

Java Laboratorv 3: Maze Recursion Java API First, we'll show you a

Laboratorv 3: Maze Recursion Java API First, we'll show you a demo of what you are trying to accomplish Download Lab03.zip from ilearn and extract the contents into your working directory. Starting Files: rawable.iava . DrawPanelava . CenterFrame.iava . MazeGUL.iava SimpleDialogs.iava MazeDriver.java Maze.java //all of your work is in this file Lab: Recursion Return Values Part I: Maze Recursion A maze is an excellent application for recursion. From a specific location in the maze (a 2D array of 0s for walls and 1s for paths), make recursive calls for all four possible directions (right, left, up, down) by adding or subtracting to the current row or column. Remember that the call stack maintains the order that methods are called (LIFO), the values of the local variables for each method call, and where the method call occurred in the calling method. When a direction that has not been tried is explored, mark that location as tried by placing the appropriate integer in the current location in the 2D array (blue in the figure). Marking a direction as tried will prevent the algorithm from exploring that location again later. If there is no solution, every location will eventually be marked as tried, and then the user is infomed that there is no solution. A recursive call in a direction already tried or a direction that is a wall can simply terminate without doing anything (removing themselves from the call stack as there is no solution in that direction) When a particular location has had all four directions leading from that location explored (either walls or directions that have been tried), the algorithm must back track or move to previous locations that have not had all four directions explored. This is easily done by letting the current location's method terminate and pick up where the previous method call left off. When this occurs, mark the location in red (see figure below). This previous method may have directions that have not been tried, or may now also be completed, in which case the back tracking continues

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!