Question: / / Applies dynamic programming to compute the largest number of / / coins a robot can collect on an n times m board
Applies dynamic programming to compute the largest number of
coins a robot can collect on an n times m board by starting at
and moving right and down from upper left to down right corner
Input: Matrix Cnm whose elements are equal to and
for cells with and without a coin, respectively
Output: Largest number of coins the robot can bring to cell n m
RobotCoinCollectionCnm
FC;
for j to m do
F jF j C j
for i to n do
FiFi Ci
for j to m do
Fi j maxF i j Fi j Ci j
return Fn m
Modify this algorithm so some cells on the board indecated by and X are inaccessible for the robot.
The input should be command line arguements in the format Columns Rows
indicates the cell is empty. indicates the cell has a coin in it X indicates the cell is inexcessable.
for example
robotCoin X X X X X X
Should produce this output:
Board Inputed:
X
X
X
X X X
Coin Collecting Table:
The optimal path with this board is:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
