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
Norma-Jean [14]
3 years ago
5

Given a collection of n nuts and a collection of n bolts, arranged in an increasing order of size, give an O(n) time algorithm t

o check if there is a nut and a bolt that have the same size. The sizes of the nuts and bolts are stored in the sorted arrays NUT S[1..n] and BOLT S[1..n], respectively. Your algorithm can stop as soon as it finds a single match (i.e, you do not need to report all matches).
Computers and Technology
1 answer:
kari74 [83]3 years ago
8 0

Answer:

See explaination

Explanation:

Keep two iterators, i (for nuts array) and j (for bolts array).

while(i < n and j < n) {

if nuts[i] == bolts[j] {

We have a case where sizes match, output/return

}

else if nuts[i] < bolts[j] {

this means that size of nut is smaller than that of bolt and we should go to the next bigger nut, i.e., i+=1

}

else {

this means that size of bolt is smaller than that of nut and we should go to the next bigger bolt, i.e., j+=1

}

}

Since we go to each index in both the array only once, the algorithm take O(n) time.

You might be interested in
In 1839, Talbot released the paper-based process which he called _ to the public.
vlabodo [156]

Answer:

I'm pretty sure it's photogenic drawing.

7 0
2 years ago
Microsoft Word cannot be used to create personalized web<br> pages.<br> OTrue<br> False
Georgia [21]

Answer:

False

Explanation:

Because Microsoft can be used to create personalized web

5 0
2 years ago
Which of the following allows data to coordinate activity between devices? Select one: a. Address bus b. Collisions c. Data bus
AnnyKZ [126]

Answer:

The correct option is D: Control Bus

Explanation:

A control bus is usually used by the Central Processing Unit to communicate with all the devices that are connected or contained within a computer. This connections are usually done via physical connections such as printed circuits or cables. It is also called a Computer bus and helps in coordinating activities between the connected devices.

5 0
3 years ago
Alonzo collects bugs. He has created a fascinating display of large insects. Collecting bugs is a(n) _____ to Alonzo.
-Dominant- [34]
The answer is hobby. He does it because he enjoys it. There is no information of him being told or paid to collect bugs, so it is a hobby.
3 0
3 years ago
Read 2 more answers
Miriam is very detail oriented within the first month of her new job as a network support specialist she became very good at dia
love history [14]
What is the question?
3 0
3 years ago
Other questions:
  • After modifying a numbered list in her presentation, Su notices the numbers and the text are too close to each other. She knows
    9·1 answer
  • Change control in application development is a formal process for changing written documentation into online documentation, and
    13·1 answer
  • A_____refers to the entire Excel file
    14·1 answer
  • The main devices in a rectifier are:
    14·2 answers
  • Each time you save a document, _____. you will need to type in the file type in which it should be saved you can select the Save
    11·1 answer
  • HELP ME PLZ QUICK Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took
    6·1 answer
  • Which type of microphone uses two metal plates?
    7·1 answer
  • In the space provided, analyze the pros and cons of becoming a member of an artistic guild. Your answer should be at least 150 w
    12·1 answer
  • LaShawn would like to post photos in a social media app, but the program needs to be modified in order to display a greater vari
    12·2 answers
  • Why does 5 g mm wave require more cells to achieve a better signal
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!