Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

=+employee to take on the international assignment?

Answered: 1 week ago