Question: Here is the pseudocode for the divide and conquer algorithm for the maximum contiguous sum with a print statement added: function m c s (

Here is the pseudocode for the divide and conquer algorithm for the maximum contiguous sum
with a print statement added:
function mcs(A,L,R)
if L==R
return (A[L])
else
C=L+R??2
Lmax=mcs(A,L,C)
Rmax=mcs(A,C+1,R)
Lhmax =- infinity
Lhsum =0
for i=C downto L inclusive
Lhsum = Lhsum + A[i]
if Lhsum > Lhmax
Lhmax = Lhsum
end
end
Rhmax =- infinity
Rhsum =0
for i=C+1 to R inclusive
Rhsum = Rhsum +A[i]
if Rhsum > Rhmax:
Rhmax = Rhsum
end
end
Smax = Lhmax + Rhmax
print (Lmax +","+ Smax +","+ Rmax)
)
end if
end function
Suppose this code is run on a list of length 8 with the following incomplete output where we've
replaced some output by variables.
-1,1,2
0,4,4
2,a,b
-1,2,3
8,10,2
c,d,10
e,18,13
18
(a) What was the original list? You do not need to know the values of the variables to answer
this.
(b) What are the values of the variables?
 Here is the pseudocode for the divide and conquer algorithm for

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!