Question
Let p(1),...,p(n) be prices of a stock for n consecutive days. A k-shot strategy is a collection of m pairs of days (b1,s1),...,(bm,sm) with 0
Let p(1),...,p(n) be prices of a stock for n consecutive days. A k-shot strategy is a collection of m pairs of days (b1,s1),...,(bm,sm) with 0 ? m ? k and1 ? b1
Design a Dynamic Programming algorithm that takes as input the prices of the n consecutive days, p(1), . . . , p(n) and for some k computes the maximum return among all k-shot strategies. (Hint: Your subproblems should be indexed by two indices.) (best runtime: O(n2k) or better)
1. Decription of subproblem
2. Base Case
3. Subproblem expressed recursively
4. The ordering of the subproblems. (The for loop(s) of the iteration.)
5. What does the algorithm return?
100 100 p(si) (si) bi) p(bi) mStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started