Stock You are given an input array A with n positive elements. Each element is the value of a sto...

Stock You are given an input array A with n positive elements. Each element is the value of a stock at that point (time). Assuming are given this future information you need to decide when to buy and sell the stock to make maximum profit (i.e. sell - buy). Write your implementations in the skeleton file stock/stock.h . The file stock/stock.cpp is for your convenience it will not be used by autograding. max_profit (18 pts) Implement, using divide and conquer, the function below which returns the maximum possible profit. template <typename Iter> typename Iter::value_type max_profit(Iter start, Iter end) { return e; } Buy and Sell (18 pts) Implement, using divide and conquer, the function below which returns a pair of iterators pointing to the buying/selling values respectively. template <typename Iter> std::pair<Iter, Iter> nax_profit_interval(Iter start, Iter end) { return std::make_pair(start, end); } Return the times (18 pts) Implement the function below which returns the indices of the buying selling values, given: 1.begin=iterator to the beginning of the container (e.g. vector), 1. start=iterator to buying element 2. end=iterator to selling element
Solved
COMPUTER SCIENCE
1 Answer
Hayden Venedam

Login to view answer.