Design a Traffic Light Controller With a Pedestrian Push Button

Quick Overview

A low-level design question about a traffic control system in which pedestrians press a button to request a crossing and the lights change. It tests modeling the controller as explicit states and transitions, safety rules between vehicle and pedestrian signals, timing, class design and testing.

Design a Traffic Light Controller With a Pedestrian Push Button

Company: Oracle

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

Design a traffic control system: traffic lights for vehicles, signals for pedestrians, and a push button that pedestrians press to request a crossing. After a press, the lights change so that pedestrians can cross. This is a low-level, object-oriented design round rather than a large-scale distributed system design, and the focus is not concurrency. Produce the design and enough code to show how the controller behaves when time passes and when the button is pressed. ```hint What the system can be in List every combination of vehicle light and pedestrian signal the system may show at once, and ask which events move it from one combination to the next. ``` ```hint A press is a request Ask whether a press should change the lights immediately, and what the system must remember if it cannot. ``` ### Clarifying Questions - Is it one crosswalk across a single road, or a full intersection with several roads and crosswalks? - Are the timings (minimum vehicle green, yellow, walk, pedestrian clearance) configuration values, and may they differ by location or time of day? - What should happen when the button is pressed many times, or while pedestrians are already crossing? - Should the design include a fail-safe mode, such as flashing lights when a fault is detected? - Does the controller drive the lamps directly, or send commands to hardware through an interface? ### What a Strong Answer Covers - An explicit finite set of states, the events (time passing, button press, fault) and the guarded transitions between them, ideally as a table - Safety invariants: pedestrians never see WALK while vehicles have green or yellow, with clearance intervals between conflicting movements - Button handling: latching the request, guaranteeing vehicles a minimum green, and ignoring presses that need no action - Classes with clear responsibilities: the controller, the state and transition definitions, the clock, and the light and button interfaces - Testability through an injected clock, and a defined fail-safe behavior - How the design extends to a full intersection or new phases without rewriting the controller ### Follow-up Questions - How would you extend the design to a four-way intersection with turn signals? - How would you test that pedestrians and vehicles are never shown conflicting signals? - An emergency vehicle needs priority. Where does that fit in your design? - The controller crashes and restarts. What should the lights show, and in what state should it resume?

Overview: A low-level design question about a traffic control system in which pedestrians press a button to request a crossing and the lights change. It tests modeling the controller as explicit states and transitions, safety rules between vehicle and pedestrian signals, timing, class design and testing.

Read the full Oracle Software Engineer interview experience this question came from

Oracle logo
Oracle
Oct 30, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

Design a traffic control system: traffic lights for vehicles, signals for pedestrians, and a push button that pedestrians press to request a crossing. After a press, the lights change so that pedestrians can cross. This is a low-level, object-oriented design round rather than a large-scale distributed system design, and the focus is not concurrency. Produce the design and enough code to show how the controller behaves when time passes and when the button is pressed.

Clarifying Questions Guidance

  • Is it one crosswalk across a single road, or a full intersection with several roads and crosswalks?
  • Are the timings (minimum vehicle green, yellow, walk, pedestrian clearance) configuration values, and may they differ by location or time of day?
  • What should happen when the button is pressed many times, or while pedestrians are already crossing?
  • Should the design include a fail-safe mode, such as flashing lights when a fault is detected?
  • Does the controller drive the lamps directly, or send commands to hardware through an interface?

What a Strong Answer Covers Guidance

  • An explicit finite set of states, the events (time passing, button press, fault) and the guarded transitions between them, ideally as a table
  • Safety invariants: pedestrians never see WALK while vehicles have green or yellow, with clearance intervals between conflicting movements
  • Button handling: latching the request, guaranteeing vehicles a minimum green, and ignoring presses that need no action
  • Classes with clear responsibilities: the controller, the state and transition definitions, the clock, and the light and button interfaces
  • Testability through an injected clock, and a defined fail-safe behavior
  • How the design extends to a full intersection or new phases without rewriting the controller

Follow-up Questions Guidance

  • How would you extend the design to a four-way intersection with turn signals?
  • How would you test that pedestrians and vehicles are never shown conflicting signals?
  • An emergency vehicle needs priority. Where does that fit in your design?
  • The controller crashes and restarts. What should the lights show, and in what state should it resume?