Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started