Page 1346 - AP Computer Science A, 7th edition
P. 1346

32. (B) For a sequential search, all n elements will need to be examined. For a binary search, the array will be chopped in half a maximum of log2 n times. When the target is in the first position of the list, a sequential search will find it in the first comparison. The binary search, which examines a middle element first, will not. Condition I is a worst case situation for both the sequential search and binary search. Condition III is approximately the middle of the list, but it won’t be found on the first try of the binary search. (The first try examines arr[n/2].) Still, the target will be located within fewer than logn tries, whereas the sequential search will need more than n/2 tries.


































































































   1344   1345   1346   1347   1348