Bird
Raised Fist0

Which of the following is the correct way to represent a notification service that sends messages to all parties in pseudocode?

easy🧠 Conceptual Q12 of Q15
LLD - Design — Food Delivery System

Which of the following is the correct way to represent a notification service that sends messages to all parties in pseudocode?

function notifyAll(parties, message) {
  for (let i = 0; i < parties.length; i++) {
    parties[i].send(message);
  }
}
ACall send(message) once without looping
BSend message only to the first party
CLoop through parties and call send(message) on each
DLoop through parties but do not send any message
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the pseudocode loop

    The code loops through each party in the parties list using a for loop.
  2. Step 2: Check the send method call

    Inside the loop, it calls send(message) on each party, ensuring all get notified.
  3. Final Answer:

    Loop through parties and call send(message) on each -> Option C
  4. Quick Check:

    Loop + send call = notify all [OK]
Quick Trick: Loop through all parties to send message [OK]
Common Mistakes:
MISTAKES
  • Sending message only once
  • Not looping through all parties
  • Calling send outside the loop

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes