stodd9503
stodd9503
15.04.2020 • 
Mathematics

(20 points) Given a collection of n nuts, and a collection of n bolts, each 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. You can assume that the sizes of the nuts and bolts are stored in the arrays NUT S[1..n] and BOLT S[1..n], respectively, where NUT S[1] < · · · < NUT S[n] and BOLT S[1] < · · · < BOLT S[n]. Note that you only need to report whether or not a match exists; you do not need to report all matches.

Solved
Show answers

Ask an AI advisor a question