Quiz — Lecture 21

Section A from memory, one line each. Section B shows your reasoning - marks are for method, not final answers. Answers are discussed in class; the exit ticket goes on a card.

Section A

A1. What precondition does binary search need?

A2. Write the loop invariant.

A3. What does (lo + hi) // 2 do at even widths?

A4. Probes for a million items: about how many?

Section B

B1. First bad version among 1..10, bad from 7: list the probes.

B2. Why start the cap search at max(pages), not 0?

Exit ticket

Answer one of these on your card in 60 seconds (choose any one):

  1. Why must the predicate be monotone for binary search?
  1. What is searched in search-on-the-answer?
  1. How many halvings for 1,000,000?

Homework