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

Computer Science & Information Technology

You might also like to view...

Which of the following is NOT a wireless technology?

A) AirPort B) Google Play C) Infrared D) 802.11ac

Computer Science & Information Technology

These symbols are inserted into logical functions to determine whether a condition is true or false—

(<) and (=), for example. A) Mathematical operators B) Logical symbols C) Comparison operators

Computer Science & Information Technology