Wednesday, June 16, 2004

Exercise[34]

Binary Search

Pre-work

  1. In Barron's AP Computer Science A, read about Binary Search on p. 329-330.
  2. Optional: Read about binary search in another text book that will be made available to you in class.
  3. Study and execute these Java implementations of binary search.
  4. Read the multiple choice questions on sorting and searching on pp. 331-345 of Barron's AP Computer Science A. Attempt to answer the questions that are related to binary search and then check your answer(s) using the answers provided on pp. 346-350.

Questions

  1. [1 point] Which questions in Barron's AP Computer Science A (pp. 331-345) involve or are related to binary search? List the question numbers only.
  2. [1 points] What is the difference between the Java implementations of binary search that implement Search<T> and the ones that implement MeteredSearch<T>?
  3. [2 points] Compare and contrast RecursiveBinarySearch and RepetitiveBinarySearch.

Create Activity

  1. [3 points] Create a multiple choice question about binary search. You question should include five choices (a - e) for the answer and only one correct answer. Your question may be inspired by a question from Barron's AP Computer Science A but must be substantially different, i.e. you should feel confident that no one would ever accuse you of plagiarizing the question.
  2. [6 points] Create two implementations of RecursiveBinaryMeteredSearch or RepetitiveBinaryMeteredSearch that are different from the ones provided. (Consider replacing the switch statement with if-else statements or calculating the value of middle differently.) Both implementations must compile and must implement MeteredSearch<T>. One implementation should be correct (to the best of your knowledge) and the other implementation should be flawed.
  3. [3 points] Indicate which of the two implementations of binary search that you are submitting is flawed and describe the flaw.