Question: In class, we solved the maximum subsequence sum problem. In that problem, you were given an input array A = [ a 1 , a

In class, we solved the maximum subsequence sum problem. In that problem, you were given an input array A = [ a1, a2,. an] I containing real numbers. You had to find the contiguous subsequence with the greatest sum. A contiguous subsequence is a subsequence from A that does not skip elements from A: in other words, it is a subsequence ai, ai+l, ai+2, ai+3aj-2, aj-3, aj that contains all elements from A that occur between the i-th and j-th elements (e.g., a5, a6, a7, a8 is a contiguous subsequence, but a5, a6, a7, a8 is not). Your challenge in this problem is to solve the maximum subsequence product problem. This problem is identical to the maximum subsequence sum problem, except now you want to find the contiguous subsequence with the greatest product ai X ai+1 X.X ak. Assume all values in the array are positive. Design a dynamic programming algorithm to solve this problem. In other words, design a function MaxSubSequenceProduct (array A) that returns indices i and j, such that I <= j. The subsequence A[i,.j] = ai, ai+1,, aj-1, aj should b the contiguous subsequence that has the greatest product ai X ai+1 X..X ak of all the contiguous subsequences from A. What is your function's running time?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!