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

(A) 6 –1 –2 5 (B) –1 2 –3 4 (C) 2 4 6 8 (D) –3
(E) 1 2 3 –8
31. A sorted list of 120 integers is to be searched to determine whether the value 100 is in the list. Assuming that the most efficient searching algorithm is used, what is the maximum number of elements that must be examined?
(A) 7 (B) 8 (C) 20 (D) 100 (E) 120
32. Consider a sorted array arr of n elements, where n is large and n is even. Under which conditions will a sequential search of arr be faster than a binary search?
I The target is not in the list.
II The target is in the first position of the list.
III Thetargetisin arr[1 + n/2].
(A) I only
(B) II only
(C) III only
(D) I and III only (E) II and III only
33. Refer to the following data field and method. private int[] arr;
/∗∗ Precondition: arr.length > 0 and index < arr.length. ∗/





















































































   603   604   605   606   607