← Quiz: Searching Git History: all 10 questions
Quiz: Searching Git History · Question 8 of 10
What does this print? (code)
What does this print?
lo, hi, tests = 0, 15, 0
while hi - lo > 1:
mid = (lo + hi) // 2
tests += 1
if mid >= 11:
hi = mid
else:
lo = mid
print(hi, tests)
- A.7 4
- B.11 4
- C.11 3
- D.15 4
Answer & explanation
Correct answer: 11 4
This is bisect on 16 commits where commit 11 is the first bad one: it tests 7, 11, 9 and 10, then reports 11 after 4 tests.
Can you get the rest right without peeking?
Take the timed Quiz: Searching Git History quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →