Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 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

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

Discrete and Combinatorial Mathematics An Applied Introduction

Authors: Ralph P. Grimaldi

5th edition

201726343, 978-0201726343

More Books

Students also viewed these Programming questions