An IT company wants to perform an analysis of revenues and expenses
of in a period of n months. The information is given in a list A[1], . . . , A[n] with
integer values. In month i the company had a deficit or surplus which corresponds to someone
positive or negative integer in position A[i]. The goal is to find a continuous interval
months with the maximum total profit for the company. Here are three examples:
(aʹ) A = [30, −50, 20, −50], where the interval with maximum total profit is from month
1 until month 1, with a profit of 30,
(bʹ) A = [30, −5, 20, −50], where the interval with maximum total profit is from month
1 until month 3 with a total profit equal to 45,
(cʹ) A = [30, −50, 20, −5, 40], where the interval with maximum total profit is from
month 3 up to month 5 with a total profit equal to 55.
Design an efficient divide and conquer algorithm. To
analyze for correctness and complexity, describing and solving the retro-
bit relation that expresses the time complexity of your algorithm.
i divided /2 until each array has only one element.Then i find the max but i dont know how to find the number of the months.
DimitriosBampos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.