Question: Write a dynamic programming algorithm that, given a sequence a 1 , , a n of numbers, finds a consecutive subsequence a s , ,
Write a dynamic programming algorithm that, given a sequence a1, , an of numbers, finds a consecutive subsequence as, , at such that the sum is maximum. Note that if ai is negative for all i, we define the maximum sum to be zero, which is obtained by selecting an empty subsequence. What is the complexity of your algorithm?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
