Bird
Raised Fist0

Given the following pseudocode for notifying parties asynchronously, what is the expected output if notify prints "Notified {user}"?

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

Given the following pseudocode for notifying parties asynchronously, what is the expected output if notify prints "Notified {user}"?

users = ["Ann", "Ben"]
for user in users:
    async_notify(user)
print("All notifications sent")
ANotified Ann Notified Ben All notifications sent
BAll notifications sent Notified Ann Notified Ben
CAll notifications sent
DNotified Ann All notifications sent Notified Ben
Step-by-Step Solution
Solution:
  1. Step 1: Understand asynchronous calls behavior

    Asynchronous calls start tasks but do not wait for them to finish immediately.
  2. Step 2: Analyze the print order

    The print statement runs immediately after starting async notifications, so "All notifications sent" prints first, then notifications complete and print their messages.
  3. Final Answer:

    All notifications sent Notified Ann Notified Ben -> Option B
  4. Quick Check:

    Async calls print after main flow [OK]
Quick Trick: Async calls don't block; main prints first [OK]
Common Mistakes:
MISTAKES
  • Assuming synchronous order
  • Ignoring async behavior
  • Expecting immediate notification print

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes