You are asked to design an algorithm to optimize profit on a stock X. The following is how the stock has been doing for the last 10 days:
Day 1: $143;
Day 2: $122;
Day 3: $121;
Day 4: $119;
Day 5: $147;
Day 6: $170;
Day 7: $172;
Day 8: $180;
Day 9: $170;
Day 10: $161.
Your algorithm should:
a) find the lowest price to buy and the highest price to sell.
b) make the buying date before the selling date
Hint: To make the algorithm more effective you may create two arrays or lists instead of one.
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we\'ll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.