Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please change code such that the indicies of the max subarray is also returned. thanks!! 58 //00nlogn) 59 int max3(int a, int b, int c)

Please change code such that the indicies of the max subarray is also returned. thanks!! image text in transcribed
58 //00nlogn) 59 int max3(int a, int b, int c) { 60 return a>b ? a>c ? a : c: bc ? b:c; 61 } 62 63 int maxSumRec(const vector int>& a, int left, int right) { 64 if(left == right) if(a[left] > 0) return a[left]; else return 0; int center = (left+right)/2; int maxLeft Sum = maxSumRec(a, left, center); int maxRight Sum = maxSumRecca, center+1, right); int start = , end = 0; int maxLeft BorderSum = 0, leftBorderSum = 0; for(int i = center; i >= left; - i) { leftBorderSum + a[i]; if(leftBorderSum > maxLeftBorderSum) { end = i; maxLeftBorderSum = leftBorderSum; int maxRightBorderSum = 0, rightBorderSum ; for(int j = center+1; j maxRightBorderSum) { start = j; maxRightBorderSum = rightBorderSum; 94 return max3 (maxLeftSum, maxRight Sum, maxLeft BorderSum + maxRightBorderSum); 95 ) 96 97 void maxSubSum3(const vector int>& a) { 98 cout

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

What is Ramayana, who is its creator, why was Ramayana written?

Answered: 1 week ago

Question

To solve by the graphical methods 2x +3y = 9 9x - 8y = 10

Answered: 1 week ago

Question

2. Develop a persuasive topic and thesis

Answered: 1 week ago

Question

1. Define the goals of persuasive speaking

Answered: 1 week ago