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. 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 (a) Determine the runtime of Search1 in Theta notation, in terms of m and n. (b) Determine the runtime of Search2 in Theta notation, in terms of m and n. (c) When m Theta(1), which algorithm has an asymptotically faster runtime? (d) When m Theta(n), which algorithm has an asymptotically faster runtime? (e) 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: 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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

Organizing Your Speech Points

Answered: 1 week ago