subject
Mathematics, 21.04.2020 22:21 MogTaee

We're looking at the price of a given stock over n consecutive days, numbered i = 1,2, …, n. For each day i, we have a price p(i) per share for the stock on that day. (We'll assume for simplicity that the price was fixed during each day.) We'd like to know: How should we choose a day i on which to buy the stock and a later day j > i on which to sell it, if we want to maximize the profit per share, p(j) - p(i)? (If there is no way to make money during the n days, we should conclude this instead.) In the solved exercise, we showed how to find the optimal pair of days i and j in time O(n log n). But, in fact, it's possible to do better than this. Show how to find the optimal numbers i and j in time O(n).

ansver
Answers: 3

Another question on Mathematics

question
Mathematics, 21.06.2019 16:30
Diana is painting statues she has 7/8 of a liter of paint each statue requires 1/20 of a liter of paint how many statues can she paint?
Answers: 3
question
Mathematics, 21.06.2019 18:30
Aswimming pool had 2.5 million liters of water in it. some water evaporated, and then the pool only had 22 million liters of water in it. what percent of the water evaporated?
Answers: 1
question
Mathematics, 21.06.2019 21:00
How do i put 3(x+7) in distributive property
Answers: 1
question
Mathematics, 21.06.2019 22:30
Complete the equation of the live through (-1,6) (7,-2)
Answers: 1
You know the right answer?
We're looking at the price of a given stock over n consecutive days, numbered i = 1,2, …, n. For eac...
Questions