Question: 6. (5 marks) Consider the following algorithm which receives a binary array A[1..n] as input. Algorithm 1 Algo Surprise (A[1..n]) if n 1 then

6. (5 marks) Consider the following algorithm which receives a binary array 

6. (5 marks) Consider the following algorithm which receives a binary array A[1..n] as input. Algorithm 1 Algo Surprise (A[1..n]) if n 1 then return (A[1], A[1], A[1]) else m = [2/2] (l1, 71, W) Surprise (A[1..m]) = (l2, 12, W2) = Surprise (A[(m + 1)..n]) if lm then if l = nm then l = n r = n else else end if l = m + l r = 12 end if if l nm then l = l r=r + n - m else l = l T = T2 end if end if w max max{w, u return (l, r, w) 1, W2, r + l} What is the result of Surprise([1, 1, 0, 1, 1, 1, 0, 1])? No justification. I only mark the answer.

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 Programming Questions!