param maze param currentPos param path The {@code Maze; object to solve param history The {@code Coordinate} obje The {@code ArrayList} of (@ from the start of the maze coordinates from start up to all the coordinates from sta The f@code ArrayList} of f@

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

The purpose of this assignment is to practice using Recursion with backtracking to solve a maze.

I need help to implement the private static void solve(Maze maze, Coordinate currentPos, ArrayList<Coordinate> path, ArrayList<Coordinate> history) method in the MazeSolver class.

@
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54°
55
56
57
58
59
600
61
62
63
64
65
66
670
68
' 69 70 71 72 73 74
* The recursive helper method that YOU will implement. This method will do all the work for
* solving the maze.
*
* @param maze The {@code Maze} object to solve.
*
@param currentPos
*
*
* @param path
*
*
*
*
* @param history
*
*
The {@code Coordinate} object that keeps track of your current position in the maze.
The {@code ArrayList} of {@code Coordinate} objects that are currently on the path
from the start of the maze to the end. This ArrayList should only contain the
coordinates from start up to your current position, and eventually should contain
all the coordinates from start to end.
The {@code ArrayList} of {@code Coordinate} objects that you have already visited.
This helps you to keep track of where you have been so you do not check the same
position more than once.
*/
private static void solve (Maze maze, Coordinate currentPos, ArrayList<Coordinate> path, ArrayList<Coordinate> history) {
//THIS IS THE METHOD THAT YOU MUST IMPLEMENT.
//YOU MAY NOT CHANGE THE METHOD HEADER
}
/**
* Private method to print the final results once a solution has been found.
* @param maze A {@code Maze} object that we wish to display.
* @param path
*
An ArrayList of {@code Coordinate} objects that are on the path from the start
of the maze to the end.
*/
private static void printResult(Maze maze, ArrayList<Coordinate> path) {
for (int i = 0; i < maze.getNumRows(); i++) {
for (int j = 0; j < maze.getNumCols(); j++) {
Coordinate current = new Coordinate(i, j);
if (current.equals(maze.getStart())) {
System.out.print("S");
Transcribed Image Text:@ 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54° 55 56 57 58 59 600 61 62 63 64 65 66 670 68 ' 69 70 71 72 73 74 * The recursive helper method that YOU will implement. This method will do all the work for * solving the maze. * * @param maze The {@code Maze} object to solve. * @param currentPos * * * @param path * * * * * @param history * * The {@code Coordinate} object that keeps track of your current position in the maze. The {@code ArrayList} of {@code Coordinate} objects that are currently on the path from the start of the maze to the end. This ArrayList should only contain the coordinates from start up to your current position, and eventually should contain all the coordinates from start to end. The {@code ArrayList} of {@code Coordinate} objects that you have already visited. This helps you to keep track of where you have been so you do not check the same position more than once. */ private static void solve (Maze maze, Coordinate currentPos, ArrayList<Coordinate> path, ArrayList<Coordinate> history) { //THIS IS THE METHOD THAT YOU MUST IMPLEMENT. //YOU MAY NOT CHANGE THE METHOD HEADER } /** * Private method to print the final results once a solution has been found. * @param maze A {@code Maze} object that we wish to display. * @param path * An ArrayList of {@code Coordinate} objects that are on the path from the start of the maze to the end. */ private static void printResult(Maze maze, ArrayList<Coordinate> path) { for (int i = 0; i < maze.getNumRows(); i++) { for (int j = 0; j < maze.getNumCols(); j++) { Coordinate current = new Coordinate(i, j); if (current.equals(maze.getStart())) { System.out.print("S");
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY