381 views
1 votes
1 votes

Consider a board game in consist of m × n grid. A coin is located at the top-left corner of an m × n grid. The coin can only move either down or right at any point in time. The ultimate goal of the game places the coin at the bottom-right corner of the grid. The following code returns the number of unique paths.

int path(int m, int n)

{

 if (m == 1 || n == 1)

 return 1;

 

 return path(m-1, n) + path(m, n-1);

}

Find the number of unique paths if grid order is 5 × 4.

  • 38

  • 25

  • 35

  • 28

1 Answer

0 votes
0 votes
Given, m=5, n=4, 5x4 board

To calculate the number of unique paths, we need to consider the number of horizontal [right] and vertical [down] moves.
For the given board, to travel from top-left to bottom-right according to the given constraints we need 4 rights/horizontal moves and 3 downs/vertical moves.
Therefore, totally we need to make 7 moves.
Therefore, number of unique paths = 7! / (4! x 3! ) = 35

Answer is option C) 35

Related questions

0 votes
0 votes
0 answers
4