Bird
0
0

Given a system where agents are assigned based on proximity, what will be the output if all agents are busy?

medium📝 Analysis Q4 of 15
LLD - Design — Food Delivery System

Given a system where agents are assigned based on proximity, what will be the output if all agents are busy?

AssignAgent(order):
  nearest = FindNearestFreeAgent(order.location)
  if nearest is None:
    return "No agents available"
  return nearest.id
A"Agent assigned"
BNearest agent's ID
CSystem crash due to null pointer
D"No agents available"
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the function behavior when no free agent exists

    If FindNearestFreeAgent returns None, the function returns "No agents available".
  2. Step 2: Confirm output for all busy agents

    Since all agents are busy, nearest is None, so output is the string message.
  3. Final Answer:

    "No agents available" -> Option D
  4. Quick Check:

    Output when busy = "No agents available" [OK]
Quick Trick: Check for None before accessing agent ID [OK]
Common Mistakes:
  • Assuming system crashes on None
  • Returning agent ID even if none free
  • Returning generic success message

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes