Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part A: Maze exploration using recursive function (30%) A Maze is given as N*N binary matrix of blocks where source block is the upper left

image text in transcribed

Part A: Maze exploration using recursive function (30%) A Maze is given as N*N binary matrix of blocks where source block is the upper left most block i.e., maze[0][0] and destination block is lower rightmost block i.e., maze[N- 1][N-1). A rat starts from source and has to reach the destination. The rat can move in four directions: left, right, up or down. In the maze matrix, O means the block is a dead end and 1 means the block can be used in the path from source to destination. Backtracking is an algorithmic technique for solving problems recursively by trying to build a solution incrementally in maze exploration Suggested Approach: Form a recursive function, which will follow a path and check if the path reaches the destination or not. If the path does not reach the destination then backtrack and try other paths. Algorithm: 1. Create a solution matrix, initially filled with O's. 2. Create a recursive function, which takes initial matrix, output matrix and position of rat (i, j). 3. if the position is out of the matrix or the position is not valid then return. 4. Mark the position output[i][j] as 1 and check if the current position is destination or not. If destination is reached print the output matrix and return. 5. Recursively call for position (i+1, j) and (i, j+1). 6. Unmark position (i, j), i.e output[i][j] = 0. Your task is to implement the given algorithm in C++ with recursive functions. You need to test the solution in a main function by creating a 2D array and print out the maze solution correspondingly if there is a path existing

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

Students also viewed these Databases questions

Question

Describe the Indian constitution and political system.

Answered: 1 week ago

Question

Explain in detail the developing and developed economy of India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = X 52+7 - 1)(x+2) dx

Answered: 1 week ago

Question

What is gravity?

Answered: 1 week ago

Question

What is the Big Bang Theory?

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago