Skip to main content

Practice ยท 1 of 3

Pipeline Bisection

stages is an ordered array of stage ids; inspect(stageId) returns true if that stage's OUTPUT is already wrong. Write firstBadStage(stages, inspect) returning the id of the FIRST stage whose output is wrong (or null if all good). Must probe at most ceil(log2(n)) + 2 times โ€” binary search the boundary.

Difficulty: intermediate

Back to lesson: Practice: Diagnose From Evidence โ€” Practice