Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following algorithm (written in pseudocode) that searches an array for an integer: Input: array A of n integers, and an integer t. Output:

image text in transcribed
Consider the following algorithm (written in pseudocode) that searches an array for an integer: Input: array A of n integers, and an integer t. Output: Whether or not A contains t for i:=1 to n do if A[i]=t then return TRUE return FALSE What is the "big-0" running time of the algorithm above, as a function of the array length n ? For an (different, but similar) algorithm that searches two arrays (the input are arrays A and B of n integers each, and an integer t, and the output is whether or not either A or B contains t ), would your response change? Why, or why not? We have seen in class that the "big- O " running time provides an upper bound on the actual running time, as the input size grows indefinitely. We have also seen a formal definition of this. What asymptotic running time would provide a lower bound on the actual running time of the above algorithm? Might it be the same function that provides an upper bound? If not, why? If so, can you come up with a formal definition that describes a function that provides both an upper and lower bound on the actual running time? (Hint: it will be very similar to the formal definition of big- OI)

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

More Books

Students also viewed these Databases questions