Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed 

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

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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions