[Solved]Let M N N Matrix Integers S Example 9 2 10 15 23 10 40 16 2 Staircase Path M Path Starts M Q37119025
Let M be an n×n matrix of integers. Here’s an example:
[9 -2 10
15 23 -10
40 16 2]
A staircase path of M is a path that starts at M[0,0] and atevery step moves right or down until it reaches M[n−1, n−1]. Forexample, in the matrix above, the path that traces 9,15,23,−10,2 isa staircase path. Clearly, there are many such paths. We say that astaircase path is optimal if among all such paths the sum of thenumbers it traces is as large as possible.
(a) Determine an optimal staircase path for the matrixabove.
(b) Consider the following greedy algorithm: Starting at M[0,0],construct a staircase path by first comparing the number to theright (if it exists) and the number below (if it exists) and thenextending the path along the larger of the two numbers. If there isa tie, arbitrarily choose one of them. Stop when you’ve reachedM[n−1, n−1]. Present an example of a matrix of integers where thegreedy algorithm outputs a staircase path that is not optimal.
(c) Given an n×n matrix M, design an efficient algorithm basedon dynamic programming that outputs the sum of the numbers in anoptimal staircase path. What is the running time of your algorithm?(Hint: Notice that we can extend the definition of an optimalstaircase path to a submatrix of M whose top left corner is M[0,0]and whose bottom right corner is M[i, j] where 0 ≤ i ≤ j ≤ n−1.Define OPT[i, j]as the sum obtained by an optimal staircase pathfrom M[0,0] to M[i, j]. Now develop a recursive formula for OPT[i,j].)
Expert Answer
Answer to Let M be an n×n matrix of integers. Here’s an example: [9 -2 10 15 23 -10 40 16 2] A staircase path of M is a path th… . . .
OR

