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

writeList(strArray); m.sort(); writeList(copyArray);
(E) Sort q = new QuickSort(strArray); String[] copyArray = makeArray(strList); Sort m = new MergeSort(copyArray); q.sort();
writeList(strArray);
m.sort();
writeList(copyArray);
Questions 34–36 refer to the Hi-Lo game described below.
Consider the problem of writing a Hi-Lo game in which a user thinks of an integer from 1 to 100 inclusive and the computer tries to guess that number. Each time the computer makes a guess, the user makes one of three responses:
• “lower” (i.e., the number is lower than the computer’s guess)
• “higher” (i.e., the number is higher than the computer’s guess)
• “you got it in < however many > tries!”
34. Suppose the game is programmed so that the computer uses a binary search strategy for making its guesses. What is the maximum number of guesses the computer could make before guessing the user’s number?
(A) 50 (B) 25 (C) 10 (D) 7 (E) 6
35. Suppose the computer used a sequential search strategy for






















































































   480   481   482   483   484