Question: 3 . 2 N Days ( 2 0 pt . ) Now, suppose you are given prices over n days. Using your solution to part

3.2 N Days (20 pt.)
Now, suppose you are given prices over n days. Using your solution to part (a) as a guide, design an O(nkQ) time algorithm that determines whether you can reach your goal, and if not, reports the maximum profit achievable. Prove your algorithms runtime and correctness.
Hint: Its helpful to reframe each day as 1) selling all the shares you own and 2) then buying a set of shares that you can afford.

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!