Backtracking - Rat In A Maze Puzzle | Algorithms
by SJ · April 13, 2015 Given a maze, NxN matrix. A rat has to find a path from source to destination. maze[0][0] (left top corner)is the source and maze[N-1][N-1](right bottom corner) is destination. There are few cells which are blocked, means rat cannot enter into those cells. Rat can move in any direction ( left, right, up and down). Input: A 2D-matrix with 0's and 1's fill in it. 0 means that cell is blocked and 1 means rat can move to that cell. Rat In A Maze Puzzle Approach: Create a solution matrix of the same structure as maze. Whenever rat moves to cell in a maze, mark that particular cell in solution matrix. At the end print the solution matrix, follow that 1's from the top left corner, it will be that path for the rat. Algorithm: print the solution matrix.Read full article from Backtracking - Rat In A Maze Puzzle | Algorithms
No comments:
Post a Comment