Reason About Binary Search with One-Call-Delayed Feedback

Quick Overview

Analyze binary search when each comparison response belongs to the previous guess rather than the current call. The exercise focuses on startup and flush semantics, response-to-guess correlation, a valid interval invariant, termination, and the call overhead of a clearly stated delayed-feedback protocol.

Reason About Binary Search with One-Call-Delayed Feedback

Company: OpenAI

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: Technical Screen

# Reason About Binary Search with One-Call-Delayed Feedback You must find a secret integer in a known inclusive range. A comparison service can report that a guess is too low, too high, or correct. Unlike an ordinary binary-search oracle, the value returned by the current call describes the **previous** guess rather than the guess just submitted. The captured prompt does not define what the first call returns, whether a separate flush operation exists, whether more than one guess may be outstanding, or whether it is safe to submit a duplicate guess solely to receive delayed feedback. It also mentions a second part that was not captured. Explain which protocol details must be clarified before this task has one implementable contract. Then give a binary-search strategy under one explicit, internally consistent delayed-feedback protocol. Track which response belongs to which guess, state the search invariant, explain termination, and analyze comparison and call complexity. Do not reconstruct the missing second part. ### Clarifying Questions to Ask - What does the first call return when there is no previous guess? - Can the client receive the last pending response without submitting another guess? - May multiple guesses be outstanding, and are responses guaranteed to remain in submission order? - Are repeated guesses or a side-effect-free flush call permitted? - What are the inclusive bounds, and is the secret guaranteed to be inside them? ### What a Strong Answer Covers - Recognition that a one-call delay changes the interaction protocol, not the comparison logic itself. - An explicit association between every returned comparison and the earlier guess it evaluates. - A valid startup and completion rule instead of silently treating the first response as current. - The usual binary-search interval invariant and overflow-safe midpoint choice. - A clear call bound for the chosen protocol and an explanation of why other protocol choices may change it. ### Follow-up Questions - If a separate `flush()` returns the pending comparison, how does the call count change? - Can useful guesses be pipelined when each new midpoint depends on the previous comparison? - How should the client handle a response that arrives out of order or names an unexpected guess ID?

Quick Answer: Analyze binary search when each comparison response belongs to the previous guess rather than the current call. The exercise focuses on startup and flush semantics, response-to-guess correlation, a valid interval invariant, termination, and the call overhead of a clearly stated delayed-feedback protocol.

|Home/Software Engineering Fundamentals/OpenAI
OpenAI logo
OpenAI
Aug 18, 2026
hardSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
4
0

Reason About Binary Search with One-Call-Delayed Feedback

You must find a secret integer in a known inclusive range. A comparison service can report that a guess is too low, too high, or correct. Unlike an ordinary binary-search oracle, the value returned by the current call describes the previous guess rather than the guess just submitted.

The captured prompt does not define what the first call returns, whether a separate flush operation exists, whether more than one guess may be outstanding, or whether it is safe to submit a duplicate guess solely to receive delayed feedback. It also mentions a second part that was not captured.

Explain which protocol details must be clarified before this task has one implementable contract. Then give a binary-search strategy under one explicit, internally consistent delayed-feedback protocol. Track which response belongs to which guess, state the search invariant, explain termination, and analyze comparison and call complexity. Do not reconstruct the missing second part.

Clarifying Questions to Ask Guidance

  • What does the first call return when there is no previous guess?
  • Can the client receive the last pending response without submitting another guess?
  • May multiple guesses be outstanding, and are responses guaranteed to remain in submission order?
  • Are repeated guesses or a side-effect-free flush call permitted?
  • What are the inclusive bounds, and is the secret guaranteed to be inside them?

What a Strong Answer Covers Guidance

  • Recognition that a one-call delay changes the interaction protocol, not the comparison logic itself.
  • An explicit association between every returned comparison and the earlier guess it evaluates.
  • A valid startup and completion rule instead of silently treating the first response as current.
  • The usual binary-search interval invariant and overflow-safe midpoint choice.
  • A clear call bound for the chosen protocol and an explanation of why other protocol choices may change it.

Follow-up Questions Guidance

  • If a separate flush() returns the pending comparison, how does the call count change?
  • Can useful guesses be pipelined when each new midpoint depends on the previous comparison?
  • How should the client handle a response that arrives out of order or names an unexpected guess ID?
Loading comments...