Design exercises
Design an elevator controller
Separate request selection from movement safety.
Understand the problem
Track elevator direction, current floor, pending stops, and door state. Scheduling chooses the next stop; a state machine enforces that movement occurs only with doors closed.
Make it concrete
Requests in the current travel direction can be grouped before reversing direction.
Trade-offs and pitfalls
Optimizing average wait can harm the worst-case wait of distant requests.
Check your understanding
Define behavior when an elevator goes out of service.
Practice this topic