Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 Price 0 1 10 11 1 2 7 -4 3 10 3 4 6 -4 Change 6 0 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 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

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

More Books

Students also viewed these Databases questions

Question

What would you do?

Answered: 1 week ago

Question

What were the issues and solutions proposed by each team?

Answered: 1 week ago

Question

3. Who would the members be?

Answered: 1 week ago