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
If the ____________ is broken on a laptop, chances are other parts are also broken.
ella [17]
Central processing Unit
8 0
3 years ago
What is the difference between operating systems and application software?
Oliga [24]
The operating system is what allows the user to interact with the computer's hardware. It has basic services such as accepting commands from the user, managing, loading, and executing programs, and managing hardware resources. Some examples of operating systems are Windows, Linux, Mac OSX, and IOS.

Application software are pieces of software that perform specific tasks such as word processors.
5 0
3 years ago
Which of the following may present a problem for Linux users?
motikmotik
Tendancy to crash hope that helped
6 0
3 years ago
Read 2 more answers
Out of a list of the values 2, 45, 18, 22, 8, and 37, what result would the MAX function return?
Vika [28.1K]
37 most likely.
No programming language is specified, and you didn't put what the function is, so assuming it's already implemented, MAX should display the highest number.
8 0
3 years ago
Read 2 more answers
A customer is looking to replace three aging network servers that are not able to keep up with the growing demand of the company
weeeeeb [17]

Answer:

c. Type 1 hypervisor installed directly on server hardware.

Explanation:

The customer plans to replace the old network services to ensure that the operation and service of the company is fast and up-to-date. The old servers will slow down the activities of the company and can also affect the overall company's output. The best option is to use and type 1 hypervisor and it should be installed on the server hardware directly.

6 0
3 years ago
Other questions:
  • What might the purpose be for a sata-style power connector on a motherboard?
    15·1 answer
  • "This part of the computer fetches instructions, carries out the operations commanded by the instructions, and produces some out
    15·1 answer
  • The following outline is used to plan a program. What is the name for this type of plan?
    7·2 answers
  • What tasks do most operating systems perform?
    15·1 answer
  • Discuss the major differences in two approaches ofprogramming i.e. Object oriented programming and structuredprogramming.
    6·1 answer
  • What responds to both visual appeal and functional needs? (1 point) A.) applied art B.) performance art C.) fine art D.) visual
    14·1 answer
  • Which of the following is a characteristic of a college savings plan
    6·2 answers
  • What is wrong with the following code? publicstatic char grade(int score) { if (score &gt;= 9) { return 'A'; } else if (score &g
    6·1 answer
  • A row-level trigger requires use of the _____ keywords and is executed once for each row affected by the triggering statement.
    7·1 answer
  • Pls need this asap
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!