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.
Answer:
<h2><em>F</em><em>o</em><em>r</em><em> </em><em>m</em><em>e</em><em> </em><em>y</em><em>e</em><em>s</em><em> </em><em>i</em><em> </em><em>g</em><em>u</em><em>e</em><em>s</em><em>s</em><em> </em><em>y</em><em>o</em><em>u</em><em> </em><em>c</em><em>a</em><em>n</em><em> </em><em>u</em><em>p</em><em>d</em><em>a</em><em>t</em><em>e</em><em> </em><em>a</em><em>n</em><em> </em><em>a</em><em>p</em><em>p</em><em> </em><em>s</em><em>t</em><em>o</em><em>r</em><em>e</em><em> </em><em>i</em><em>n</em><em> </em><em>a</em><em>n</em><em>y</em><em> </em><em>d</em><em>e</em><em>v</em><em>i</em><em>c</em><em>e</em></h2><h2><em>I</em><em>'</em><em>m</em><em> </em><em>n</em><em>o</em><em>t</em><em> </em><em>s</em><em>u</em><em>r</em><em>e</em></h2>
<h2><em>×_× mello ×_×</em></h2>
Answer:
The prototype for the function is written below:-
void printArray(int [],int);
Explanation:
The prototype of the function is written above.Since the function does not return a value so it has to be of type void.Then following is the name of the function.Following that the arguments in the parenthesis.We need not to provide the name of the arguments we just have to define it's type.So for the array we have to just write int [] and for integer variable just int.