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
Router 1 is configured with static NAT. Addressing on the router and the web server are correctly configured, but there is no co
marin [14]

Answer:

The router NAT configuration has an incorrect inside local address.

Explanation:

The term Inside in a <em>Network Address Translation (NAT) </em>context refers to networks owned by an organisation that must be translated. When NAT is configured, hosts within this network have addresses in one space (known as the local address space). These hosts appear to those users outside the network as being in another space (known as the global address space).

The term Outside refers to those networks to which the stub network connects, and which are not under the control of an organisation. Also, hosts in outside networks can be subject to translation, and can thus have local and global addresses

7 0
2 years ago
The National Institute of Standards and Technology (NIST) guidelines list four different states a mobile device can be in when y
Ahat [919]

Answer:

quiescent

Explanation:

The National Institute of Standards and Technology (NIST) guidelines list four different states a mobile device can be in when you extract data. The quiescent mode is a dormant mode that conserves battery life while maintaining user data and performing other background functions.

4 0
3 years ago
Which careers use web browsers
oksano4ka [1.4K]
All of the above. If that’s not an option if it’s multiple choice let me know. Everyone uses web browser/the internet no matter the career.
5 0
2 years ago
Is designed to access a computer or operating system without the knowledge or permission of the user.
kramer

Answer:

Spyware

Explanation:

Spyware is a type of program that is installed with or without your permission on your personal computers to collect information about users, their computer or browsing habits tracks each and everything that you do without your knowledge and send it to remote user.

5 0
2 years ago
What is a characteristic of an open software license
Darya [45]

Answer: Something people can change and share. It is usually given the bad name of have a bunch of fake information and bugs. Wikipedia is a good example of an open source website but it is not a program.

Explanation: An open source program is a program where you have free rein to basically do whatever you want to it.

3 0
3 years ago
Other questions:
  • Which is the process that a wireless router uses to translate a private ip address on internal traffic to a routable address for
    14·1 answer
  • What does it mean to read visual and audio text
    7·1 answer
  • You created the following dictionary relationships = {'Jimmy':'brother', 'Carol':'sister'}. You then executed the following code
    5·1 answer
  • You are trying to log in to your old computer, and can't remember the password. You sit for hours making random guesses... I'm s
    10·1 answer
  • Items that are cut or copied are placed on the Clipboard.
    6·2 answers
  • Write a simple hello world program in python 3
    8·2 answers
  • B =(-21) (0) + (-50) ÷ (-5)​
    9·1 answer
  • 1. List three tabs that make up the Ribbon
    14·1 answer
  • Can you please help me with this crossword puzzle, I am having trouble with numbers 5 down and 22 across.
    5·2 answers
  • Why are pirated software considered a threat?​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!