Bird
Raised Fist0

Which pseudocode snippet correctly verifies if a user has exceeded their request limit?

easy📝 Syntax Q3 of Q15
Rest API - Rate Limiting and Throttling
Which pseudocode snippet correctly verifies if a user has exceeded their request limit?
Aif requests[user] > limit + 1: allow_access()
Bif requests[user] < limit: deny_access()
Cif requests[user] == limit + 1: allow_access()
Dif requests[user] >= limit: deny_access()
Step-by-Step Solution
Solution:
  1. Step 1: Understand the limit check

    The condition should block when requests are equal to or exceed the limit.
  2. Step 2: Analyze each option

    if requests[user] >= limit: deny_access() correctly denies access when requests are greater than or equal to the limit.
  3. Final Answer:

    if requests[user] >= limit: deny_access() -> Option D
  4. Quick Check:

    Check if condition blocks at limit or above [OK]
Quick Trick: Block when requests ≥ limit [OK]
Common Mistakes:
MISTAKES
  • Using less than instead of greater than or equal
  • Allowing requests exactly at the limit
  • Checking for limit + 1 instead of limit

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes