1 2 3 4 1 O 2 3 x O 5 X XXX 4 5 6 O XIX O O O O O
Several coins are placed in cells of an n × m board, no more than one coin per cell. A robot, located in the upper left cell of the board, needs to collect as many of the coins as possible and bring them to the bottom right cell. On each step, the robot can move either one cell to the right or one cell down from its current location. When the robot visits a cell with a coin, it always picks up that coin. In addition, some cells (shown by X’s) on the board are inaccessible for the robot. You need to apply dynamic programming to find the maximum number of coins the robot can collect and a path it needs to follow to do this. As an example, we give a 5 by 6 board as follows:
- define your objective function
- write down the recurrence relation of the objective function
- make a DP table and fill it based on your recurrence relation
- backtrack from the destination to find out the optimal paths. You should explain the backtracking strategy, and mark the optimal paths on the above bo
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images