Katkat

Design read-heavy org chart subordinate counts

MicrosoftSoftware Engineer · Onsite

Last updated

Evaluates understanding of tree/graph data modeling, dynamic indexing, and consistency and concurrency control for maintaining aggregate subordinate counts under updates; Category/Domain: System Design.

You are given manager→direct-report relationships for an organization (an employee has at most one direct manager; the top-level employee has none). Build a data structure/service that supports:

  1. Query (read-heavy): given an employee id, return how many total people are in their reporting chain below them (all direct and indirect reports).

  2. Update: a relationship can change (e.g., employee X moves from manager A to manager B). After an update, future queries must return correct counts.

Discuss the data model, algorithms, and how you would keep queries fast while handling updates safely (e.g., avoiding cycles).