Question: Implement the pseudo algorithm of the Find Maximum Subarray problem using a divide and conquer approach to find a contiguous subarray whose values have the

Implement the pseudo algorithm of the Find Maximum Subarray problem using a divide and conquer approach to find a contiguous subarray whose values have the largest sum. Given the input and output requirements, your implement should follow the pseudocode provided in the textbook and lecture. You can simulate a period of 100 days with a randomly generated price ranging from $50 to $120 and calculate daily changes in prices from the generated prices. Use a table below as a model for 17 days, prices, and changes in price.

Day 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Price 100 113 110 85 105 102 86 63 81 101 94 106 101 97 94 90 97
change 13 -3 -25 20 -3 -16 -23 18 20 -7 12 -5 -22 15 -4 7

Inputs: stock prices for 100 days

Outputs: a sequence of 100 days

prices and price changes for 100 days

i and j indices indicating low and high index for the largest sum on each subarray of left, right and cross

a max profit identifying i and k indices calculated from the subarray

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!