100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

How to Design an Elevator System?

Learn how to design an elevator system using the SCAN/LOOK algorithm, cost-based dispatching, and destination dispatch for scale.

mediumQ72 of 224 in System Design Est. time: 5 minsLast updated:
Open Code Lab

Expected Interview Answer

An elevator system is designed around a central dispatcher that models each car’s state (position, direction, queued stops) and assigns hall calls to the car that can serve them with least cost, most commonly using a variant of the SCAN/look elevator-scheduling algorithm to minimize direction reversals and wait time.

Each elevator car exposes its current floor, direction (up/idle/down), and an ordered set of pending stops; the dispatcher receives hall calls (floor + desired direction) and cabin calls (destination pressed inside a car) and must pick the best car for each hall call using a cost function that favors cars already moving toward the caller in the same direction over idle or oppositely-moving cars. The classic SCAN/LOOK algorithm has each car continue in its current direction servicing all pending stops before reversing, which avoids starvation and minimizes unnecessary direction changes compared to naive nearest-car assignment. For scale (many elevators, many floors, high traffic), the dispatcher can batch and re-evaluate assignments as new calls arrive, and modern “destination dispatch” systems collect the destination floor upfront at the hall panel to group passengers heading the same way into the same car, cutting stops and travel time. The system must also handle edge cases: emergency stop, weight limits, door obstruction sensors, and fairness so no floor is starved indefinitely.

  • A cost-based dispatcher minimizes average wait time versus naive first-come assignment
  • The SCAN/LOOK algorithm avoids starvation and unnecessary direction reversals
  • Destination dispatch groups same-direction passengers to reduce total stops
  • Modeling per-car state cleanly supports scaling to many cars and floors

AI Mentor Explanation

Designing an elevator system is like a captain deciding which fielder should chase a ball hit toward the boundary, favoring whoever is already running in that direction over someone standing still elsewhere on the field. The captain does not recall a fielder mid-sprint just because a closer stationary fielder exists if that fielder is already moving the right way; instead, the fielder finishes the run in that direction before reversing course. This “keep going one way, finish everything along the path, then reverse” logic is exactly the SCAN algorithm an elevator dispatcher uses to assign and serve calls efficiently.

Step-by-Step Explanation

  1. Step 1

    Model car state

    Each elevator tracks its current floor, direction, and an ordered queue of pending stops (hall calls + cabin calls).

  2. Step 2

    Score candidate cars for a new call

    The dispatcher scores each car by cost (distance, direction match, current load) and prefers a car already moving toward the caller.

  3. Step 3

    Serve stops via SCAN/LOOK

    A car continues in its current direction, servicing every pending stop along the way, before reversing direction at the last stop.

  4. Step 4

    Reassign as new calls arrive

    The dispatcher re-evaluates assignments as new hall calls come in, potentially reassigning if a better-positioned car becomes available.

What Interviewer Expects

  • Describes per-car state (position, direction, pending stops) and a cost-based dispatcher
  • Names the SCAN/LOOK algorithm and explains why it beats naive nearest-car assignment
  • Mentions destination dispatch as an optimization that groups same-direction passengers
  • Considers fairness/starvation and real-world constraints (weight limits, door sensors, emergency stop)

Common Mistakes

  • Assigning every call to the nearest idle car regardless of direction, causing excessive reversals
  • Not distinguishing hall calls (direction-only) from cabin calls (specific destination)
  • Ignoring starvation — a floor at the edge of the building never getting served under heavy load
  • Forgetting real-world constraints like weight sensors, door obstruction, and emergency override

Best Answer (HR Friendly)

An elevator system keeps track of where every car is and which way it is going, and when someone presses a call button, it picks the car that can get there most efficiently, usually one already heading that direction rather than an idle car further away. Each car keeps moving in one direction, picking up and dropping off everyone along the way, before reversing, which keeps average wait times low and prevents any floor from being ignored.

Code Example

SCAN-based elevator call assignment (simplified)
class Elevator:
    def __init__(self, id, floor=0):
        self.id = id
        self.floor = floor
        self.direction = "idle"  # "up" | "down" | "idle"
        self.stops = set()

    def cost_for_call(self, call_floor, call_direction):
        if self.direction == "idle":
            return abs(self.floor - call_floor)
        moving_toward = (
            (self.direction == "up" and call_floor >= self.floor) or
            (self.direction == "down" and call_floor <= self.floor)
        )
        same_direction = call_direction == self.direction
        if moving_toward and same_direction:
            return abs(self.floor - call_floor)
        return abs(self.floor - call_floor) + 1000  # heavy penalty, wrong way


def assign_call(elevators, call_floor, call_direction):
    best = min(elevators, key=lambda e: e.cost_for_call(call_floor, call_direction))
    best.stops.add(call_floor)
    if best.direction == "idle":
        best.direction = "up" if call_floor > best.floor else “down”
    return best.id

Follow-up Questions

  • How would you implement destination dispatch and why does it reduce total travel time?
  • How do you prevent a distant floor from being starved under heavy traffic?
  • How would you handle a bank of elevators serving 50 floors during a morning rush?
  • What real-world constraints (weight sensors, door obstruction) does the scheduler need to respect?

MCQ Practice

1. What does the SCAN/LOOK algorithm do for elevator scheduling?

SCAN/LOOK has a car finish all pending stops in its current direction before reversing, which reduces wasted travel and avoids starvation.

2. Why does destination dispatch (collecting the target floor upfront) improve efficiency?

Knowing destinations upfront lets the system batch same-direction passengers into fewer cars, cutting the number of stops per trip.

3. What is a key difference between a hall call and a cabin call?

A hall call (up/down button on a floor) only indicates desired direction, while a cabin call (inside the car) specifies the exact destination floor.

Flash Cards

What does an elevator dispatcher optimize for?Assigning each call to the car with least cost, favoring cars already moving toward the caller in the same direction.

What is the SCAN/LOOK algorithm?A car continues in its current direction serving all pending stops before reversing, avoiding starvation and excess reversals.

What is destination dispatch?Collecting the destination floor at the hall panel upfront to group same-direction passengers into fewer cars.

Hall call vs cabin call?A hall call gives direction only; a cabin call (pressed inside) specifies the exact destination floor.

1 / 4

Continue Learning