Question: The perfect maze is represented as a two-dimensional matrix as defined below. public class Maze { private char[,] M; private int size; public Maze(int n)

The perfect maze is represented as a two-dimensional matrix as defined below.

public class Maze { private char[,] M; private int size; public Maze(int n) { ... } (2) private void Initialize( ) { ... } // Called by the constructor (6) private void Create( ) { ... } // Called by the constructor (2) private void DepthFirstSearch(int i, int j, bool[,] visited) { ... } // Called by Create (12) public void Print( ) { ... } }

1) Implement each of the above methods, keeping in mind the following requirements. a. The method Initialize populates matrix M with blank characters and walls (e.g. '-' and '|'). The size of the matrix may be greater than n to accommodate the "walls" and any other boundaries. (show screenshot)

b. The method Create invokes DepthFirstSearch to build the perfect maze. As the depth-first search is performed, if two or more adjacent positions are unvisited, then one direction is randomly chosen. (show screenshot)

2) Implement a main program to test the methods of Maze for n=0, 1, 2, 5, 10, 20. (show screenshot)

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!