Bird
0
0

How can an elevator state machine handle simultaneous requests from multiple floors efficiently?

hard📝 Trade-off Q8 of 15
LLD - Design — Elevator System
How can an elevator state machine handle simultaneous requests from multiple floors efficiently?
ABy randomly selecting a floor to visit next
BBy ignoring all requests except the first one
CBy maintaining a queue of floor requests and prioritizing based on current direction
DBy resetting to Idle after each request
Step-by-Step Solution
Solution:
  1. Step 1: Understand multiple request challenge

    Elevator must decide order to serve floors efficiently without unnecessary movement.
  2. Step 2: Use queue and prioritization

    Maintaining a queue and prioritizing requests in current direction reduces wait time and travel.
  3. Final Answer:

    By maintaining a queue of floor requests and prioritizing based on current direction -> Option C
  4. Quick Check:

    Queue and priority [OK]
Quick Trick: Queue requests and prioritize direction [OK]
Common Mistakes:
MISTAKES
  • Ignoring requests after first
  • Random floor selection
  • Resetting state too often

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes