Given the following function definition, what modifications need to be made to the search function so that it finds all occurrences of target in the array?
int search(const int array[], int target, int numElements)
{
int index=0;
bool found=false;
while((!found) && (index < numElements))
{
if(array[index] == target)
found=true;
else
index++;
}
if(found==true)
return index;
else
return -1;
}
a. Add another parameter to indicate where to stop searching
b. Add another parameter to indicate where to start searching
c. This already can find all occurrences of a given target
d. Have the function return the whole array
b. Add another parameter to indicate where to start searching
You might also like to view...
Assume that, in addition to the operations read(x) and write(x), a database has the operation increment(x,C), which (atomically) increments the value stored in record x by the constant C, which might be positive or negative. Design a conflict table for these operations for use in an immediate-update pessimistic concurrency control.
What will be an ideal response?
A(n) ________ is text that prints at the bottom of every page of a document
Fill in the blank(s) with correct word
?In a structure chart, a(n) _____ line, with a diamond on one end, indicates that a control module determines which subordinate modules will be invoked.
A. ?method B. ?condition C. ?class D. ?attribute
Support websites that use Web 2.0 technologies differ from earlier support websites primarily in ____.
A. including frequently asked questions (FAQs) B. the authoring language used to build and maintain the site C. improved site navigation tools D. an emphasis on collaboration and communication among users