Question: aximum Subsequence Sum. Recall the maximum subsequence sum ( MSS ) problem, for which we gave a ( nlogn ) divide - and - conquer
aximum Subsequence Sum. Recall the maximum subsequence sum MSS problem,
for which we gave a nlogn divideandconquer algorithm. In this problem, you will develop a dynamic
programming algorithm with running time n to solve the problem.
The input is an array A containing n numbers, and the goal is to find a starting index s and ending index t
where s t so the following sum is as large as possible: As As At At
For example, in the array
A
the maximum is achieved by summing the third through seventh elements, to get
so the optimal solution is s and t When all entries are positive, the entire array is the answer
s and t n In general, we will allow the case s t a sequence of only one element but not allow
empty subsequences.
Give a dynamic algorithm to find the value of a maximum subsequence sum. For this problem, you only
need to return the value, not the maximum subsequence itself.
Hint Define OP T j to be the maximum sum of any subsequence that ends at index j
Derive a dynamic algorithm for MSS by following these steps:
Write a recurrence and base case for OP T j
Write pseudocode for a bottomup dynamic programming algorithm that computes the values OP T j
for all j from to n Your algorithm should take n time.
Describe in one sentence how we can find the value of the optimal solution to the original MSS problem
if we know the value OP T j for all j
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
