Question: Write in C, we can write info in txt file, there's no pre-requerements In Istanbul stock exchange (Borsa Istanbul), you are eligible to buy only

Write in C, we can write info in txt file, there's no pre-requerementsWrite in C, we can write info in txt file, there's no

In Istanbul stock exchange (Borsa Istanbul), you are eligible to buy only 1 unit of stock only 1 time, moreover, you, then, are able to sell it at a later time. To buy and sell, you should wait for the close of trading for that day. Your aim is to maximize your profit. Thus, that is better you buy a unit of stock on a lower price and sell it back on a higher price. The lowest and highest prices may not always work as expected. Since, in a stock market there can be descents as well as accents (see below figure). 11 10 9 Day 8 7 0 1 10 11 1 Price 2 7 -4 3 10 3 4 6 Change -4 6 0 1 2 3 4 We should find a sequence of days over which the net change from the first day to the last is maximum. It is asked you to dig for some contiguous days whose values have the largest sum. Your client is expecting to see those days average value, their sum, and when best to buy and sell. See the below example, i.e., sixteen days of Borsa Istanbul values. At most 100 days of data might be found in a text file. Ex: 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 13 -3 -25 20 -3 -16 -23 18 20 -7 12 -5 -22 15 -4 7 |||5. A A[8.. 11] Sum = 43 Buy before day 8 (after day 7). sell after day 11. AVG = 10.75 Example Run#1: Buy before day 8 (after the day 7 ends) sell after day 11 (before the day 12 begins). Sum of these 4 days: 43 Average value for these 4 days: 10.75

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!