Skip to content

Interview question · Planning & Control Patterns

Tree search gives better answers but the latency budget is eight seconds. What do you do?

Spend the search where it pays, spend it in parallel, stop at a deadline with the best answer so far, and move the rest of the search offline where nobody is waiting.

expertNewUpdated Nov 2026

TL;DR: Do not run the full search on every request. Answer with one attempt plus a fast check, and search only when the check fails or confidence is low. When you search, go wide and shallow: expand branches in parallel, use a cheaper model for expansions and the strong model once at the end, and run as an anytime search that returns the best verified candidate at the deadline. Then move search offline: use its best trajectories to improve prompts, few-shot examples or a fine-tuned model, so the single attempt gets better and fewer requests need search at all.

How to approach it

Ask for the numbers: how much better search is, on which requests, how long one expansion and one check take, and whether the eight seconds is a hard limit or a target percentile. Then budget the time explicitly, because "make it faster" is not an answer.

A strong answer

Budget the eight seconds. Illustrative timings: an expansion call 1.8 s, a check 0.4 s, a final answer 1.2 s, overhead 0.5 s.

def search_plan(budget_s, expand_s, check_s, final_s, overhead_s, width):
    per_level = expand_s + check_s              # one level runs in parallel
    levels = int((budget_s - final_s - overhead_s) // per_level)
    return {"levels": levels, "candidates": levels * width,
            "spare_s": round(budget_s - final_s - overhead_s - levels * per_level, 2)}

plan = search_plan(8, 1.8, 0.4, 1.2, 0.5, width=6)
print(plan["levels"], plan["candidates"], plan["spare_s"])  # => 2 12 1.9

Sequentially, the budget allows two expand-and-check rounds, so two candidates. In parallel at width six, the same two levels give twelve. Depth costs latency; width costs money. Within a latency budget, go wide.

Search only when it pays. Most requests are answered well by one attempt. Run the single attempt and a fast check first (about 2 seconds); for the requests that pass, stop. Search the remaining share with the remaining time. If 80% pass, search runs on a fifth of traffic and the median latency barely moves.

Make each expansion cheaper. A smaller, faster model proposes branches; the verifier prunes; the strong model writes the final answer from the best branch. Cache expansions for repeated sub-problems.

Anytime, with a deadline. The search keeps the best verified candidate so far and returns it when time runs out, rather than failing or overrunning. If nothing has passed by the deadline, return the single-attempt answer with a flag, or hand off.

Move the search offline. The best trajectories search finds are training signal. Use them as few-shot examples, to improve the prompt, or to fine-tune the model that makes the first attempt. Over time the single attempt passes more often and online search runs less.

Or change the product. If the use case allows, answer fast and improve in the background: show a first answer at two seconds and an improved one when search completes, or move the task to an asynchronous flow with a notification.

What interviewers probe next

"The eight seconds is a p95 target, not a hard limit." Then the budget applies to the tail: gate search so that the slowest 5% (searched requests) still finish in time, which usually means a stricter deadline on the searched path.

"How do you know search is still worth it after the first attempt improves?" Track the share of requests that fail the first check and the gain search adds on them. When both shrink, narrow or remove search.

"What if the verifier is the slow part?" Use a fast pre-filter (schema, cheap rules) on all candidates and the slow verifier only on the top few.

How it's scored

Weak: Uses a faster model everywhere or drops search.

Hire: Parallelises search, reduces depth, and searches only when a first attempt fails a check.

Strong Hire: Budgets the time explicitly, goes wide and shallow in parallel, gates search on a failed check, uses cheaper expansion models with a strong final step, returns the best answer at a deadline, distils search results offline into the first attempt, and considers asynchronous product options.

Common mistakes

  • Running full search on every request.
  • Deep sequential search that cannot fit any reasonable budget.
  • No deadline, so slow cases overrun instead of returning the best so far.
  • Treating search as permanent rather than as a source of training signal.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 6, and the site remembers where you stopped in each one.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in raises your free answers from 5 to 6 per topic, adds an applied lesson in every topic and easy practice tests, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented. Post a correction or another way to answer.