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
What were the names of Henry VIII's six wives?
timurjin [86]

Answer:

Jane Seymour,Anne Boleyn,Katherine of Aragon,Anne of Cleves,Katherine Howard,Katherine Parr

Explanation:

7 0
1 year ago
Read 2 more answers
Cari brought 2 pounds of grapes at the grocery store she ate 5 ounces of the grapes on way home what is the weight of the grapes
sveta [45]

Answer:

27 ounces

Explanation:

You can convert 2 pounds into 32 ounces then subtract the 5 ounces that she ate from that 32.

7 0
3 years ago
How does 5G technology enhance the Internet of Things (ioT) ?
Naddik [55]

Answer:

Internet of Things are everyday items that uses the internet, 5G internet enhances the internet service allowing you to connect, receive, or send information in places where internet would usually be slower like crowded areas. Through antennas using spectrum which carries information through different types of waves, it overall makes the internet service better, making the appliances on that internet service faster.

Explanation:

Internet of Things are basically any everyday item that has software that connects to the internet, in which that item sends or even receives data from it connecting to different servers using an internet service.

5G is a 5th generation technology that also connects to servers through an internet service. This 5G technology allows the items to receive information faster, which overall approves the internet service. One of the proud examples of 5G technology is our modern-day phones/appliances. 5G technology allows you to connect to an internet service and send information or receive information faster than 4G technology.

For your answer, since "internet of things are everyday items that uses the internet, 5G internet enhances the internet service allowing you to connect, receive, or send information in places where internet would usually be slower like crowded areas. Through antennas using spectrum which carries information through different types of waves, it overall makes the internet service better, making the appliances on that internet service faster."

Hope this helps.

4 0
2 years ago
If the supply of computer engineers increases at the same time that the demand for these workers decreases, what would be the MO
stiv31 [10]

Answer:

Option C is correct.

Explanation:

When the supply of system engineers rises while demand for such workers falls at the similar period, Wages will drop while competition for employment rises.

According to the law of demand, when the supply of one commodity is increased then the demand for other commodity falls. So, the following option  C is correct according to the following scenario.

Other options are incorrect because they are not relevant according to the following scenario.

5 0
3 years ago
Bob works at a cafe where he earns $11 an hr. which of the following graphs describes the amount of money that bob earns after x
Sergio039 [100]
Where are the graphs?
8 0
3 years ago
Read 2 more answers
Other questions:
  • Into which of these files would you paste copied information to create an integrated document?
    13·2 answers
  • [PROGRAMMING] A ____ signal indicates that a specific amount of time should pass before an action starts.
    13·1 answer
  • What action makes RAM on your computer disappear?
    12·2 answers
  • <img src="https://tex.z-dn.net/?f=3x%20-%205%20%3D%203x%20-%207" id="TexFormula1" title="3x - 5 = 3x - 7" alt="3x - 5 = 3x - 7"
    12·1 answer
  • What does the Finder do?
    7·1 answer
  • Is a psychrometer more likely used at a beach or a desert in California
    12·1 answer
  • Braxton is writing a program to design t-shirts. Which of the following correctly sets an attribute for color?
    7·1 answer
  • Transitive spread refers to the effect of the original things transmitted to the associate things through the material, energy o
    6·1 answer
  • How to implement switch statement in Python?
    11·2 answers
  • A Network Intrusion Detection System watches for potentially malicious traffic and _______ when it detects an attack.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!