Roll Up Alert Counts Through an Industrial Asset Hierarchy
Last updated: November 29, 2026
Quick Overview
Given parent-child edges describing an asset hierarchy (site, line, equipment) and each asset's own alert count, compute every asset's total alerts including all descendants and return the k assets with the highest totals, breaking ties by asset id.
C3 AI
November 29, 20260
0
0 solved
Given parent-child edges describing an asset hierarchy (site, line, equipment) and each asset's own alert count, compute every asset's total alerts including all descendants and return the k assets with the highest totals, breaking ties by asset id.
Reliability dashboards in C3 AI applications let an operator start at a plant and drill down to the line and piece of equipment generating alerts, so aggregating over an asset tree is everyday work. The interviewer checks tree traversal without recursion limits, handling of a forest with several roots, and sensible validation of bad hierarchy data such as cycles or two parents.
What the Interviewer Expects
- Build an adjacency list and find roots as nodes that never appear as a child
- Compute subtree sums in post-order, iteratively so deep hierarchies do not overflow the stack
- Include assets that appear only in the alert map or only in edges
- Detect cycles and multiple parents instead of looping forever or double counting
- Select the top k with a heap and a deterministic tie-break
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- If an asset can legitimately belong to two parents (a shared compressor), how do you avoid double counting at the site level?
- Alerts stream in continuously. How do you keep subtree totals current without recomputing the whole tree?
- How would you answer the same question for alerts in a sliding 24-hour window?
- How would you store the hierarchy so a single subtree query is fast in a database?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: edges as (parent, child) pairs and alerts mapping an asset to its own count (missing means 0). The hierarchy should be a forest: each node has at most one parent and there are no cycles. ...
High-Level Design
Build children lists and a has_parent set while scanning edges; a second parent is rejected right there. Roots are nodes with no parent. If every node has a parent there is a cycle, and in general...