🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)
  1. A.7 4
  2. B.11 4
  3. C.11 3
  4. 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 →