PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Microsoft

Traverse an Org Chart by Level

Last updated: May 10, 2026

Quick Overview

This question evaluates understanding of tree and graph data structures, transforming flat employee-manager relations into a hierarchical org chart, level-order traversal, and reasoning about data integrity issues such as cycles, missing managers, or multiple roots.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Data Scientist

Traverse an Org Chart by Level

Company: Microsoft

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given an organization's reporting structure as a flat list of employee-manager relationships. Exactly one employee is the root (the CEO) and has no manager. Example input schema: - `employee_id: int` - `employee_name: string` - `manager_id: int | null` Task: 1. Convert the flat reporting structure into a tree. 2. Return the org chart from top to bottom, one level at a time. 3. Each level should be shown in full before moving to the next level. Example output format: - `[[CEO], [VP1, VP2], [Mgr1, Mgr2, Mgr3], ...]` Discuss: - your data structures, - time and space complexity, - and how you would handle invalid input such as cycles, missing managers, or multiple roots.

Quick Answer: This question evaluates understanding of tree and graph data structures, transforming flat employee-manager relations into a hierarchical org chart, level-order traversal, and reasoning about data integrity issues such as cycles, missing managers, or multiple roots.

Related Interview Questions

  • Sort Three Categories In Place - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Implement SFT Sample Packing - Microsoft (medium)
  • Implement SQL Table and DNA Ordering - Microsoft (medium)
  • Solve power jumps and graph tour - Microsoft (hard)
Microsoft logo
Microsoft
Feb 25, 2026, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
8
0

You are given an organization's reporting structure as a flat list of employee-manager relationships. Exactly one employee is the root (the CEO) and has no manager.

Example input schema:

  • employee_id: int
  • employee_name: string
  • manager_id: int | null

Task:

  1. Convert the flat reporting structure into a tree.
  2. Return the org chart from top to bottom, one level at a time.
  3. Each level should be shown in full before moving to the next level.

Example output format:

  • [[CEO], [VP1, VP2], [Mgr1, Mgr2, Mgr3], ...]

Discuss:

  • your data structures,
  • time and space complexity,
  • and how you would handle invalid input such as cycles, missing managers, or multiple roots.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Microsoft•More Data Scientist•Microsoft Data Scientist•Microsoft Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.