This question evaluates HTTP and JSON parsing, CSV processing, hierarchical data modeling, sorting, and algorithmic efficiency for building and printing an organizational chart.
You will solve two practical coding tasks.
You are given an HTTP endpoint that returns JSON describing transit stops.
Assume the response body is valid JSON shaped like:
{
"stops": [
{"id": "123", "name": "South Station", "description": "Commuter rail hub"},
{"id": "456", "name": "Park Street", "description": "Red/Green lines"}
]
}
name
description
(may be missing or empty)
<name> - <description>
You are given a CSV file where each row contains:
employee_name,title,department,manager_name
manager_name
is empty for the top-level leader.
Print the organization structure so that each manager appears before their reports.
Print one employee per line with 2 spaces of indentation per level:
For each manager, print their direct reports in lexicographic order by employee_name.
Input rows (order in file is arbitrary):
Alice,CEO,Executive,
Bob,CFO,Finance,Alice
Carol,Analyst,Finance,Bob
Dave,Intern,Finance,Carol
Eve,COO,Operations,Alice
Frank,CTO,Engineering,Alice
Expected output:
Alice
Bob
Carol
Dave
Eve
Frank
manager_name
refers to an employee present in the file.