Data Structures & AlgorithmsModerateCodeforces Div2 D · GATE CS

Assertion (A): Binary search on the answer requires that the feasibility predicate is monotone. Reason (R): Only a monotone predicate lets us discard half of the answer range after each test.

  1. A. Both A and R are true, but R is not the correct explanation of A
  2. B. Both A and R are true, and R is the correct explanation of A
  3. C. A is true, but R is false
  4. D. A is false, but R is true

Correct answer: B. Both A and R are true, and R is the correct explanation of A

If feasibility is true for some value, every larger (or smaller) value is true too, so each test rules out a whole half of the range. Without monotonicity the halving step is unsafe.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic