Design an elevator system

Design the classes and scheduling logic for a building's lifts.

Why interviewers ask it

It tests state machines, scheduling and concurrency, and there's no single right answer, so your reasoning is what gets marked.

Functional requirements

Non-functional requirements

From version 1 to the final design

  1. Version 1: one lift with a list of requested floors, visited in order of arrival.
  2. Version 2: one lift using LOOK scheduling: sweep up, then down.
  3. Version 3: several lifts and a controller that gives each hall call to the lowest-cost lift.
  4. Version 4: safety states (doors, overload, maintenance) and strategies for busy times.

The design, step by step

  1. Each lift serves its stops with the LOOK algorithm: keep going in one direction, serving stops on the way, then turn around — like a lift operator sweeping up and down.
  2. A controller assigns each hall call to the best lift: idle and near, or already moving towards that floor in the same direction.
  3. Each lift has a state machine that enforces safety: doors must be closed before moving.

Deep dives

Common mistakes

Not true: Dispatch: serving calls strictly in the order they were made keeps the lift's travel shortest.
In fact: The lift then zig-zags between floors. Picking up the calls that lie on its way, in its current direction, moves more people with less travel.

In the interview

A controller receives hall calls and gives each one to the lift with the lowest cost: near, idle, or already heading that way. Each lift serves its stops with the LOOK algorithm — continue in one direction, then reverse. A state machine per lift guarantees the doors are closed before it moves.

Part of Unit 7: Low-level design questions in the free System Design course.