1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olga nikolaevna [1]
3 years ago
15

In this question, we give two implementations for the function: def intersection_list(lst1, lst2) This function is given two lis

ts of integers lst1 and lst2. When called, it will create and return a list containing all the elements that appear in both lists. For example, the call: intersection_list([3, 9, 2, 7, 1], [4, 1, 8, 2])could create and return the list [2, 1]. Note: You may assume that each list does not contain duplicate items. a) Give an implementation for intersection_list with the best worst-case runtime. b) Give an implementation for intersection_list with the best average-case runtime.
Computers and Technology
1 answer:
castortr0y [4]3 years ago
6 0

Answer:

see explaination

Explanation:

a)Worst Case-time complexity=O(n)

def intersection_list(lst1, lst2):

lst3 = [value for value in lst1 if value in lst2]

return lst3

lst1 = []

lst2 = []

n1 = int(input("Enter number of elements for list1 : "))

for i in range(0, n1):

ele = int(input())

lst1.append(ele) # adding the element

n2 = int(input("Enter number of elements for list2 : "))

for i in range(0, n2):

ele = int(input())

lst2.append(ele) # adding the element

print(intersection_list(lst1, lst2))

b)Average case-time complexity=O(min(len(lst1), len(lst2))

def intersection_list(lst1, lst2):

return list(set(lst1) & set(lst2))

lst1 = []

lst2 = []

n1 = int(input("Enter number of elements for list1 : "))

for i in range(0, n1):

ele = int(input())

lst1.append(ele)

n2 = int(input("Enter number of elements for list2 : "))

for i in range(0, n2):

ele = int(input())

lst2.append(ele)

print(intersection_list(lst1, lst2))

You might be interested in
"In about 100 words, describe the idea behind software as a service (SaaS). In your answer, include at least three examples of e
Mama L [17]

Answer:

Explanation:

Saas refers to software as a service and can also be called software on demand .

It Isa software that is deployed over the internet rather than requiring to install an application .It offers different devices such as pay as you go , subscription model and service on demand model .

Only a compatible browser is needed to access the software .

Electronic packages or components that aree offered as an Saas

1)Shopify

2)Big commerce

3)Slack

3 0
3 years ago
You speak to a business owner that is taking in almost $2,000 in revenue each month. The owner still says that they’re having tr
Serga [27]
Let's say for example that the business is taking in $2000 of revenue.  That is the amount that the business collected for it's services - like for fixing the computer.  What if though it costs $500 for the equipment (that's an expense).  Now they only made $1500.  Now the customer complains and says that the computer isn't fixed properly so the company sends out a techie for 2 additional hours.  They need to pay their employee (another expense).  Now the $1500 is down to $1400.  They would have utilities to keep their lights on and insurance and many other expenses.

Your profit looks like this:
Profit = Revenue - Expenses
7 0
3 years ago
The Hudson Engineering Group (HEG) has contacted you to create a conceptual model whose application will meet the expected datab
alexdok [17]

Answer:

The diagram of the ER and depreciation is in the attachments.

3 0
3 years ago
For businesses and organizations under recent compliance laws, data classification standards typically include private, confiden
Mnenie [13.5K]
Answer: True






Explanation:
6 0
2 years ago
Describe the function<br>ms word, Acess, Elexel, Power point<br>Publisher and Outlook​
marta [7]

Answer:

Write documents consisting mainly of text, Create databases, Create tables for organizing and calculating data, Create presentations to display in front of groups to display data and other info, Create advanced documents such as magazines, flyers, coupons, and other things, Organize your day and easily manage contacts and emails.

6 0
3 years ago
Other questions:
  • Answer this question please
    6·1 answer
  • It takes 2 seconds to read or write one block from/to disk and it also takes 1 second of CPU time to merge one block of records.
    10·1 answer
  • A(n) _____ might be written by a programmer or it might be created through a DBMS utility program.
    6·1 answer
  • List at least three benefits of automated testing?
    13·1 answer
  • Why would you use quotation marks in a search string when conducting an internet search?
    12·1 answer
  • In 200 words or more, please describe the Cyber Security Enhancement Act. Include when it was implemented and what it's purpose
    12·1 answer
  • What is the main purpose of a web crawling program
    15·1 answer
  • Which symbol is used for an assignment statement in a flowchart?
    13·1 answer
  • How to implement switch statement in Python?
    11·2 answers
  • Data elements in a relational database are organized into ____
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!