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
Which statements describe the use of styles in Word? Check all that apply.
algol [13]

Answer:

can be used to make word docments look the same

Explanation:

4 0
3 years ago
Read 2 more answers
Money left over after the bills are paid is referred to as
sveta [45]
Change is what is left over 

ex. the cashier tells you "here is your leftover change sir/ma'am "<span />
3 0
4 years ago
Read 2 more answers
Nonprocedural access to a database
777dan777 [17]

Answer:

Option D: All of above.

is the correct answer.

Explanation:

  • Non-procedural access is the feature of the database.
  • This means that when a database is created in a database management system (DBMS) using data definition language (DDL), it will be accessed every time using a data manipulation language (DML). The standard DML is SQL. SQL stands for Sequential Query Language.
  • This feature of database ultimately improves the software productivity.
  • Most of the tools of Database Management systems (DBMSs) support the non-procedural access.
  • This feature permits a user to submit queries to a database without knowing how to retrieve data.

i hope it will help you!

4 0
3 years ago
Controlling inflation is the job of the __________________.
n200080 [17]
B. Federal Reserve................
8 0
3 years ago
Read 2 more answers
Which of the following is a valid byte?<br><br> 11100<br> 11011011<br> 00000000<br> 10022011
SVETLANKA909090 [29]

Answer:

11011011

00000000

Explanation:

10022011 cant be an answer because bits are composed of 0s and 1s

and 11100 is too small.

3 0
2 years ago
Other questions:
  • Top/bottom rules allows user to apply conditional formatting cells that fall within the top or bottom numbers or percentile. how
    7·1 answer
  • Which is true about POP3 and IMAP for incoming email?
    10·1 answer
  • Which TranscribeMe tag should you use if you are unable to make out a word or phrase due to a difficult accent, poor audio, or a
    6·1 answer
  • What do you mean by real time system? Why real time system needs to response within limited time?
    6·1 answer
  • Kristi, an event planner, wants to store caterers’ names and contact information in an organized manner. Kristi will MOST LIKELY
    13·1 answer
  • dash is a set of communication standard using for transferring file information between computers in a network​
    5·1 answer
  • How many times is the body of the loop executed?
    8·1 answer
  • What is smarta Art ? ​
    10·1 answer
  • What company was affected by the cloudbleed vulnerability?
    14·1 answer
  • What do you mean by computer ethics?​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!