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
HELP PLEASE NOW ASAP BRAINLIEST
charle [14.2K]
<span>Josie lives in an area where there are frequent power cuts. She should use a UPS (Uninterruptible Power Supply). It protects against damage to a computer's hard drive (data) in case of a sudden shutdown.

Hope this helps!</span>
7 0
3 years ago
Read 2 more answers
What is an elliptic curve cryptosystem (ECC)?
andrezito [222]

Answer:

d. Provides a stronger cryptographic result with a shorter key.

Explanation:

The elliptic curve cryptosystem (ECC) is a public key cipher that provides higher security than other public key cryptosystems, such as the RSA, with shorter key.

So the correct answer is:

d. Provides a stronger cryptographic result with a shorter key.

3 0
2 years ago
Noi needs to send some documents to a client in another company. Which device can she use to make digital copies of the paper fi
soldier1979 [14.2K]
D scanner She can scan the files and email a digital copy.
4 0
2 years ago
Read 2 more answers
Who develop punch card​
monitta

Explanation:

The standard punch card (for computers) was invented and developed by Herman Hollerith. But the idea of punch cards was already long invented, used to control Jacquard looms.

Jacquard looms were looms that used punch cards to control the pattern a loom weaves.

The idea of punch cards in Jacquard looms also influenced Charles Babbage, who decided to use punched cards to control the sequence of computations in his proposed analytical engine. Unlike Hollerith's cards of 50 years later, which were handled in decks like playing cards, Babbage's punched cards were to be strung together.

7 0
2 years ago
Tech a says that a direct tpms system uses a pressure sensor located in each wheel
Feliz [49]

Tech a says that a direct tpms system uses a pressure sensor located in each wheel. This is a TRUE statement.

Explanation:

  • A tire-pressure monitoring system (TPMS) is an electronic system designed to monitor the air pressure inside the pneumatic tires on various types of vehicles. A TPMS reports real-time tire-pressure information to the driver of the vehicle, either via a gauge, a pictogram display, or a simple low-pressure warning light.
  • Direct TPMS uses a sensor mounted in the wheel to measure air pressure in each tire. When air pressure drops 25% below the manufacturer's recommended level, the sensor transmits that information to your car's computer system and triggers your dashboard indicator light.
  • Mounted inside a tire assembly on valve stems or wheel rims, the sensors are usually powered by 3-volt lithium ion batteries, but some use 1.25-volt nickel metal hydride batteries. There are developments underway that promise battery-less sensors in the future, having the potential to dramatically change TPMS markets
  • The tire pressure monitor system that uses a valve-stem-type transmitter is the direct reading type of TPMS.

8 0
3 years ago
Other questions:
  • Sarah's research shows that business information management professionals also perform the duties of other professionals. Which
    9·1 answer
  • What is the name of a popular high-level computer programming and scripting language that is the name of a snake?
    10·1 answer
  • Which computer network component allows data transfers from one computer to another through a telephone line?
    11·2 answers
  • What type of engineer works on cleaning up oil spills?
    8·2 answers
  • When troubleshooting a desktop motherboard, you discover the network port no longer works. What is the best and least expensive
    12·1 answer
  • An inventory clerk, using a computer terminal, views the following on screen: part number, part description, quantity on hand, q
    8·1 answer
  • Which of these is the fastest transmission medium?
    11·2 answers
  • If you have 60fps on your laptop tell me one way you can go to 240fps
    14·2 answers
  • Think of some local businesses that have websites. Look online and identify two different websites for businesses or services in
    13·1 answer
  • A(n) Blank______ database management system allows users to create, read, update, and delete data in a relational database. Mult
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!