Question: 2. Consider the following procedure, which takes a list L, ts length n < and a positive integer l as parameters function MYSTERY(L, n,

2. Consider the following procedure, which takes a list L, ts length 

2. Consider the following procedure, which takes a list L, ts length n < and a positive integer l as parameters function MYSTERY(L, n, l) for i from 1 to n - l + 1 do for j from i+ 1 to n-l+ 1 do matched-true for k from 0 to l - 1 do if Li+k Lj+k then matched-false end if end for if matched is still true then return (i, j) end if end for end for return reporting failure end function (a) Walk through this procedure with some examples (some promising samples might be L = [3, 1, 7, 2, 7, 2,5] with n = 7 and k = 2, or L = [1, 2, 3, 1, 2, 4, 2] with n = 6 and k = 3). What does it seem to do? When it returns an ordered pair, what information is it conveying? (b) What is the worst-case runtime of this algorithm, in big-O notation as a function of n and k? Explain your reasoning.

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!