Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given two lists A of size m and B of length n, our goal is to construct a list of all elements in list A

image text in transcribed

Given two lists A of size m and B of length n, our goal is to construct a list of all elements in list A that are also in list B. Consider the following two algorithms to solve this problem. procedure Search 1 (List A of size m, List B of size n) Initialize an empty list L. SORT* list B. for each item a A, if BinarySearch(a, B) notequalto 0 then Append a to list L. return L procedure Search2(List A of size m, List B of size n) Initialize an empty list L. for each item a A, if LinearSearch(a, B) notequalto 0 then Append a to list L. return L Determine the runtime of Search 1 in theta notation, in terms of m and n. Determine the runtime of Search 2 in theta notation, in terms of m and n. When m theta(1), which algorithm has an asymptotically faster runtime? When m theta(n), which algorithm has an asymptotically faster runtime? Find a function f(n) so that when m theta(f(n)), both algorithms have equal runtime asymptotically

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5 The mechanics of the circular flow model.

Answered: 1 week ago

Question

1 The difference between a command system and a market system.

Answered: 1 week ago

Question

4 How the market system adjusts to change and promotes progress.

Answered: 1 week ago