viewing paste Unknown #27609 | Text

Posted on the
1 2 3 4 5 6 7 8 9
A binary search algorithm is written (as in the modules, for example) which searches a pre-sorted array for some user-defined value, clientData.  If clientData is stored in the array, it returns its array position, and if not found, it returns -1 (again, just like in the modules).  Assume the array to be searched has 100 data elements in it. (Check all that apply):
 
[NOTE: due to common off-by-one interpretations when counting such things, if your predicted answer is within one (+1 or -1) of a posted option below, you can assume your prediction and the choice you are looking at are equivalent and check that option.]
 
    A.  It will always return with an answer in 7 or fewer comparisons of data.
    B.  It may require as many as 99 comparisons of data before it returns.
    C.  It will always return with an answer in 3 or fewer comparisons of data.
    D.  It might return to the client with an answer after only one comparison of data.
 
Viewed 789 times, submitted by Guest.