Question: 3 . 1 Two Days ( 2 0 pt . ) Suppose we are only looking at prices over two days ( i . e

3.1 Two Days (20 pt.)
Suppose we are only looking at prices over two days (i.e., n =2). Design an O(kP) dynamic programming algorithm that computes the maximum amount of profit you can make buying stocks on the first day and selling stocks on the second day. Prove the runtime and correctness of your algorithm.
Hint: Let M[l] be the maximum amount of profit you can make by buying l dollars of stock on the first day. Write a recursive relationship for M[l].

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 Programming Questions!