Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function void solveMaze (vector maze, int x, int y) {} that takes in a maze and the end destination and the output has

Write a function void solveMaze (vector<vector<int>> maze, int x, int y) {} that takes in a maze and the end destination and the output has to print the coordinate path of the solved maze.

You will use a stack to solve a maze. The input is an array of is and Os and the row and column of the destination. 1 means that the block can be used for a path to the destination and 0 means it cannot. The beginning of the path is 0, 0. The output is the series of coordinates (row, column) of the path to the destination. Your code will be checked to ensure that you used a stack.

The path can proceed up, down, left or right but not diagonally.

The main method will read in the input and place it into an array. It will pass the array and the destination into a method called solve Maze. You write the method solve Maze.

Sample Input 1:
1 0 1 1
1 1 1 0
0 1 0 1
1 1 1 1
23

Sample Output 1:
(0, 0) -> (1, 0) -> (1, 1) -> (2, 1) -> (3, 1) -> (3, 2) -> (3, 3) -> (2, 3)

Step by Step Solution

3.45 Rating (158 Votes )

There are 3 Steps involved in it

Step: 1

The idea is to use dfs and after that backtrack the path from point xy to 00 For this a array ... 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

Document Format ( 2 attachments)

PDF file Icon
609a990bb01a8_30792.pdf

180 KBs PDF File

Word file Icon
609a990bb01a8_30792.docx

120 KBs Word File

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

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions

Question

Fig.3 Graph

Answered: 1 week ago

Question

Can partitioned join be used for r r.A s? Explain your answer

Answered: 1 week ago