5. Here is the divide-and-conquer pseudocode for the MCS, abbreviated - see the notes for the full version. function mcs (A,L,R) if L == R else return (A [L]) C = (L+R) // 2 Lmax = mcs (A,L,C) Rmax mcs (A,C+1,R) Smax straddle max of the (sub)list end end print (Lmax, Smax, Rmax) return (max ([Lmax, Rmax, Smax])) (a) If we call mcs([-1,4,-1,3,8,-2],0,5) what will the values be in the order they are [5 pts] printed? You may not need all the entries. (b) Explain why it is not possible, for any list at all, for the output to be: Solution: -1 3 4 4 16 10-3-12109 2 [10 pts]

icon
Related questions
Question
5. Here is the divide-and-conquer pseudocode for the MCS, abbreviated - see the notes for the
full version.
function mcs (A,L,R)
if L == R
else
return (A [L])
C = (L+R) // 2
Lmax = mcs (A,L,C)
Rmax
mcs (A,C+1,R)
Smax
straddle max of the (sub)list
end
end
print (Lmax, Smax, Rmax)
return (max ([Lmax, Rmax, Smax]))
(a) If we call mcs([-1,4,-1,3,8,-2],0,5) what will the values be in the order they are [5 pts]
printed? You may not need all the entries.
(b) Explain why it is not possible, for any list at all, for the output to be:
Solution:
-1 3 4 4 16 10-3-12109
2
[10 pts]
Transcribed Image Text:5. Here is the divide-and-conquer pseudocode for the MCS, abbreviated - see the notes for the full version. function mcs (A,L,R) if L == R else return (A [L]) C = (L+R) // 2 Lmax = mcs (A,L,C) Rmax mcs (A,C+1,R) Smax straddle max of the (sub)list end end print (Lmax, Smax, Rmax) return (max ([Lmax, Rmax, Smax])) (a) If we call mcs([-1,4,-1,3,8,-2],0,5) what will the values be in the order they are [5 pts] printed? You may not need all the entries. (b) Explain why it is not possible, for any list at all, for the output to be: Solution: -1 3 4 4 16 10-3-12109 2 [10 pts]
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer