Question
I have been given an array of list of integers. I need to assume my first element is maximum contiguous sum. Then I have to
I have been given an array of list of integers. I need to assume my first element is maximum contiguous sum. Then I have to find maximum contiguous sum of list excluding the first element. Then I have to see check if my assumed contiguous sum (the first element) is my real answer or I have to extend to the whole list. I need algorithm for this recursive method in JAVA.
For example:
A = {100, -50, 5, 3}
Assumed_sum (first element) = 100
Max_sum_from_subset_exculding_first_element = 8
But when I extend first element to the whole list, my sum is less than 100.
So, my contiguous sum is 100 which is my first element.
A = {100, -6, 5, 3}
Assumed_sum = 100
Max_sum_from_subset_excluding_first_element = 2
But when I extend first element to the whole list, my sum is 102.
So, my contiguous sum will be 102.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started