Given the following function definition, will repeated calls to the search function for the same target find all occurrences of that 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. Yes
b. No
c. Impossible to tell without looking at the values of the array
d. It depends on the value of target.
b. No
You might also like to view...
Describe the difference between a queue and a priority queue.
What will be an ideal response?
Answer the following statements true (T) or false (F)
1. Many recovery diskettes are designed to boot MS-DOS and they use MS-DOS commands in the recovery process. 2. Typically, a user accesses a computer through an application programming interface and the program communicates with the operating system through an application program’s interface. 3. Under MS-DOS, a user cannot communicate directly with the operating system. 4. Under MS-DOS, the default drive and the system prompt are displayed by the operating system. 5. A delimiter, usually a comma, separates an MS-DOS command from its parameters and (if there are several) the parameters from each other.