You are in a rectangular maze organized in the form of M N cells/locations. You are starting at the upper left corner (grid location: (1; 1)) and you want to go to the lower right corner (grid location: (M;N)). From any location, you can move either to the right or to the bottom, or go diagonal. I.e., from (i; j) you can move to (i; j + 1) or (i + 1; j) or to (i+1; j +1). Cost of moving right or down is 2, while the cost of moving diagonally is 3. The grid has several cells that contain diamonds of whose value lies between 1 and 10. I.e, if you land in such cells you earn an amount that is equal to the value of the diamond in the cell. Your objective is to go from the start corner to the destination corner. Your prot along a path is the total value of the diamonds you picked minus the sum of the all the costs incurred along the path. Your goal is to nd a path that maximizes the prot. Write a dynamic programming algorithm to address the problem. Your algorithm must take a 2-d array representing the maze as input and outputs the maximum possible prot. Your algorithm need not output the path that gives the maximum possible prot. First write the recurrence relation to capture the maximum prot, explain the correctness of the recurrence relation. Design an algorithm based on the recurrence relation. State and derive the time bound of the algorithm. Your algorithm should not use recursion

Respuesta :

Answer:

Following are the description of the given points:

Explanation:

A) The Multiple greedy approaches could exist, which could be to reach for the closest emergency diamond, and yet clearly we are going to miss some very essential routes in that case. So, it can make every argument quickly, and seek to demonstrate a reference case for that.

B) An approach to the evolutionary algorithm and its users are going to just have states M x N. But each state (i, j) indicates the absolute difference between the amount of the selected diamond and the amounts of the costs incurred.

DP(i, j) = DimondVal(i, j) + max ((DP(i, j-1)-2), (DP(i-1,j-1)-3))

DP(i, j) is a description of the state.

DimondVal(i, j) is the diamond value at (i j), 0 if there is no diamond available.

This states must calculate the states of M N  and it involves continuous-time for each State to determine. Therefore the amount of time of such an algo is going to be O(MN).