Question: The input to this problem is an array A [ l . . n ] of real numbers. You need to find out what the
The input to this problem is an array Aln of real numbers. You need to find out what the highest value is that can be obtained by summing up all numbers of a contiguous subsequence Ai Ai Aj of A If A does not contain negative numbers, the problem is trivial and can be solved by summing up all the elements of A It becomes more tricky when A contains a mix of positive and negative numbers though. For instance, for A the solution is For A the solution is The sum of the numbers of an empty subsequence is There exists a brute force solution that solves this problem in On but it is also possible to solve the problem in linear time. In this problem, you are asked to design a dynamic programming algorithm that solves the problem described above in linear time. a Characterize the structure of an optimal solution. Show how you would decompose the solution into subproblems and recursively define the optimal solution by expressing it in terms of optimal solutions for smaller problems. State and define all your notations for full credit. b Present your algorithm in pseudocode. c Briefly explain how and why your algorithm works. d Give a brief explanation of why your algorithm indeed runs in linear time.
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
