[Solved]Design Dynamic Programming Algorithm Problem Define Original Problem Function Takes Parame Q37248841
Design a dynamic programming algorithm for the problem.
• Define the original problem as a function that takes parameters,and return some results.
• Define the subproblems
• Write recursive formula that relates a problem’s solution tosolutions of smaller subproblems.
• Finally write out pseudocode for the algorithm (using top-downmemoization or bottom-up)
Suppose a list P[1.. ] gives the daily stock price of a certain company for a duration of n days, we want to find an optimal day d to buy the stock and then a later day d2 to sell the stock, so that the profit is maximized (i.e., P[d2l P[di] is maximized. For example, if P[1.. .6 20, 10, 30, 50, 5, 14 Then we should buy in at day 2, and sell at day 4 to earn profit of 50- 10 per share. (Simply to buy before sell Show transcribed image text Suppose a list P[1.. ] gives the daily stock price of a certain company for a duration of n days, we want to find an optimal day d to buy the stock and then a later day d2 to sell the stock, so that the profit is maximized (i.e., P[d2l P[di] is maximized. For example, if P[1.. .6 20, 10, 30, 50, 5, 14 Then we should buy in at day 2, and sell at day 4 to earn profit of 50- 10 per share. (Simply to buy before sell
Expert Answer
Answer to Design a dynamic programming algorithm for the problem. • Define the original problem as a function that takes paramet… . . .
OR

