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
yan [13]
3 years ago
9

(20 points) 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 to 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:
Blababa [14]3 years ago
6 0

Answer:

Check the explanation

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] {

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

}

else {

what this means is that the size of bolt is lesser 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
Review the portion of the application above. Record any changes or corrections that need to be made and why.
crimeas [40]

Answer:

Necessary Corrections: First Name and Last Name are recorded in incorrect boxes. Scribbles on errors instead of making corrections Does not include information in the SSN or Desired Salary blank Does not list which position she is applying for Has box checked that she has worked for the company, but does not say when For education just wrote “Yes” instead of listing the high school and address Justification: All of this make the applicant appear less professional and hurt her chances of getting hired. She is not following the directions properly, and she is not asking questions so that she can accurately fill out the application.

(I got a 100% so I know its correct)

4 0
2 years ago
Determining Correct Date Function What function text would you use to put today's date and time in a cell? 0 =TODAYO =NOWO O NOW
Murrr4er [49]

Current date formula:

=TODAY()

Current time formula:

=NOW()

As you can see, the =TODAY() formula only includes the day, month and year. The =NOW() function displays more information, showing the day, month, year, hour and minutes (using a 24-hour clock)

if useful mark as brainliest

3 0
3 years ago
The difference between natural and technological system
kari74 [83]
Natural systems are systems that came into being by natural processes. Like the rain cycle.

Technological systems are those to whom people intervened or designed. Like diverting water for a rider for land irrigation.
5 0
2 years ago
What is a feature of webmail
Fantom [35]

Answer:

Webmail allows the users to access their emails as long as they have access to an Internet connection and a web browser. This also means that the user cannot read an old email or draft a new email offline.

8 0
3 years ago
Who wont me???????????????
Svet_ta [14]

Answer:

whatatattatata

Explanation:

what are u talking about

8 0
3 years ago
Read 2 more answers
Other questions:
  • During the charging of a storage battery, what is the temperature that the electrolyte solution must never exceed?
    6·1 answer
  • A company has recently learned of a person trying to obtain personal information of employees illegally. According to which act
    15·2 answers
  • The blue bar across the top of the screen informs you of the Screen Title, or what step you are on.
    5·1 answer
  • Assume the availability of a function is_prime. Assume a variable n has been associated with positive integer. Write the stateme
    15·1 answer
  • Looking for friends, anyone up for it?
    12·2 answers
  • Please Help! <br> I need good Anime to watch!
    7·1 answer
  • How to design remote access policy using the appropriate access controls for systems,applications, and data access
    6·1 answer
  • PLEASE I NEED HELP WITH THIS, IS FOR TODAY
    10·2 answers
  • To find information on a network use a ____
    14·1 answer
  • Think of some local businesses that have websites. Look online and identify two different websites for businesses or services in
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!