Question: Rat in the maze question. A maze is given as N*N binary matrix of blocks (0 means the block is a dead end and

Rat in the maze question. A maze is given as N*N binary

Rat in the maze question. A maze is given as N*N binary matrix of blocks (0 means the block is a dead end and 1 means the block could be used as part of path) where source block is the upper leftmost block (maze[0][0]) and the destination block is lower rightmost block (maze[0][0]). Write a method helpRat(int[][] matrix) to help rat to see whether there is a path from source to destination. If the paths exist(there may be more than one), print one of the paths. Otherwise, print "there is no such path". Note the rat could move forward, backward, up and down. e.g. there is a path in maze 1 and no path in maze 2. More than one paths are in the maze 3.

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 Programming Questions!