In an elevator system design, what is the primary responsibility of the Request class?
Think about what a user does when they want to use an elevator.
The Request class models a user's call to the elevator, specifying the floor and direction they want to go. It does not control movement or track elevator status.
Which of the following best describes the relationship between the Elevator and Floor classes in a typical elevator system design?
Consider how an elevator knows which floors it can go to.
The Elevator class typically maintains a list or reference to Floor objects it can visit. Floors do not contain elevators, and inheritance is not appropriate here.
In a high-rise building with 50 floors and 10 elevators, which design choice best improves the scalability of handling elevator requests?
Think about balancing load and avoiding conflicts among elevators.
Assigning each elevator its own queue and coordinating via a scheduler allows better load distribution and scalability. Centralized queues can become bottlenecks, and no coordination leads to inefficiency.
For the Elevator system's Request class, which tradeoff best describes using an event-driven approach over polling to handle requests?
Consider how the system reacts to new requests and resource usage.
Event-driven systems react immediately to requests, reducing CPU waste from constant checking, but require more complex event handling logic. Polling is simpler but less efficient.
In a building with 20 floors and 5 elevators, during peak hours, each floor generates on average 10 elevator requests per minute. If each elevator can process 15 requests per minute, what is the minimum size of the request queue to avoid dropping requests?
Calculate total incoming requests per minute and total processing capacity.
Total incoming requests = 20 floors * 10 requests = 200 per minute. Total processing capacity = 5 elevators * 15 requests = 75 per minute. The queue must buffer the difference (200 - 75 = 125) plus some margin. At least 100 is a reasonable minimum to avoid dropping requests.
