Issue Order for Stream Operations With Event Dependencies
Last updated: November 29, 2026
Quick Overview
Given n operations labeled 0 to n-1 and dependency pairs (a, b) meaning a must complete before b, return an execution order that always issues the lowest-numbered ready operation, or an empty list if the dependencies contain a cycle.
NVIDIA
November 29, 20260
0
0 solved
Given n operations labeled 0 to n-1 and dependency pairs (a, b) meaning a must complete before b, return an execution order that always issues the lowest-numbered ready operation, or an empty list if the dependencies contain a cycle.
Framed around CUDA Graphs and multi-stream scheduling, where kernels and copies are connected by event waits. NVIDIA interviewers use it to check Kahn's algorithm, cycle detection, and the deterministic tie break, which matters for reproducible profiling runs.
What the Interviewer Expects
- Builds adjacency lists and in-degree counts from the dependency list
- Uses a min-heap of ready nodes for deterministic lowest-id ordering
- Detects cycles by comparing output length to n
- States O((n + e) log n) complexity
- Explains how the same structure gives levels for parallel issue across streams
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
- How would you group operations into waves that can run concurrently on different streams?
- How do you report the actual cycle instead of just an empty list?
- If each op has a duration, how do you compute the critical path length?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Ops 0..n-1, edges (a, b) meaning a before b. Output a full ordering in which, at each step, we take the smallest id whose dependencies are satisfied. If no full ordering exists (a cycle, which in ...
High-Level Design
Kahn's algorithm. Compute in-degrees, push every zero in-degree op into a min-heap, then repeatedly pop the smallest, append it, and decrement in-degrees of its successors, pushing those that reach ze...