Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Suppose that you been offered the opportunity to invest in Apple Inc. The stock price of the company is volatile. You can buy only

image text in transcribed

4. Suppose that you been offered the opportunity to invest in Apple Inc. The stock price of the company is volatile. You can buy only one unit of stock at a time and then sell it at a later date, buying and selling after the close of trading for the day. To compensate for this restriction, you can learn what the price of the stock will be in the future. Your goal is to maximize your profit. The figure below shows the price of the stock over a 17-day period. 1 20 110 100 90 80 70 60 0 1 4 5 8 10 11 12 13 14 15 16 Day Price Change 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 100 113 110 85 105 102 86 63 81 101 94 106 101 79 94 90 97 13 -3 -25 20 -3 -16 -23 18 20 -7 12-5-22 15 - 4 7 | Information about the price of stock after the close of trading over a period of 17 days is given above. The horizontal axis of the chart indicates the day, and the vertical axis shows the price. The bottom row of the table gives the change in price from the previous day. Requirements: a. Formulate an efficient recursive algorithm using divide and conquer strategy to perform the above task. b. Develop a non-recursive, linear-time algorithm for above problem. C. Analyze the time complexity for requirement 1. Output: Maximum Profit: Day to buy: Day to sell: The output should be displayed directly on screen. 4. Suppose that you been offered the opportunity to invest in Apple Inc. The stock price of the company is volatile. You can buy only one unit of stock at a time and then sell it at a later date, buying and selling after the close of trading for the day. To compensate for this restriction, you can learn what the price of the stock will be in the future. Your goal is to maximize your profit. The figure below shows the price of the stock over a 17-day period. 1 20 110 100 90 80 70 60 0 1 4 5 8 10 11 12 13 14 15 16 Day Price Change 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 100 113 110 85 105 102 86 63 81 101 94 106 101 79 94 90 97 13 -3 -25 20 -3 -16 -23 18 20 -7 12-5-22 15 - 4 7 | Information about the price of stock after the close of trading over a period of 17 days is given above. The horizontal axis of the chart indicates the day, and the vertical axis shows the price. The bottom row of the table gives the change in price from the previous day. Requirements: a. Formulate an efficient recursive algorithm using divide and conquer strategy to perform the above task. b. Develop a non-recursive, linear-time algorithm for above problem. C. Analyze the time complexity for requirement 1. Output: Maximum Profit: Day to buy: Day to sell: The output should be displayed directly on screen

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

What is a deferred coupon bond?

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago