maze_shortest path

How to solve this??

1 Like

Bfs can be used to solve it.

1 Like

I didn’t solve this one yet, but it seems as simple shortest path problem, so simply use one of the well known algorithm f.e.:

2 Likes

@hariprasath

This is a very known problem called as Rat in a Maze.

You can use BFS or Backtracking to solve this problem.

@betlista i think you do not need to use Dijkstra algorithm for this problem.

3 Likes

this function can solve the question recursive and easy :slight_smile:
int minCost(int cost[][C],int m, int n)
{
if (n < 0 || m < 0)
return INT_MAX;
else if (m == 0 && n == 0)
return cost[m][n];
else
return cost[m][n] + min( minCost(cost,m-1, n-1),
minCost(cost,m-1, n),
minCost(cost,m, n-1) );
}

5 Likes

thanks!!!

1 Like

thanks!!!

y dijkstra??

1 Like