HomeInterview QuestionsIf T2 and T3 complete, then trigger T4 and T5 in p…

If T2 and T3 complete, then trigger T4 and T5 in parallel. How would you handle the dependency experience?

🟡 Medium Conceptual Junior level
1Times asked
Jun 2026Last seen
Jun 2026First seen

💡 Model Answer

To manage the described dependency, model the tasks as nodes in a directed acyclic graph (DAG). T2 and T3 are prerequisites for T4 and T5, so draw edges T2→T4, T2→T5, T3→T4, and T3→T5. A topological sort of the DAG gives an execution order that respects dependencies. In practice, you can use a workflow engine such as Apache Airflow, AWS Step Functions, or Azure Data Factory, which internally builds the DAG and schedules tasks. When T2 and T3 finish, the engine automatically marks T4 and T5 as ready and launches them concurrently. If you implement it manually, maintain a counter for each downstream task; decrement the counter when a prerequisite finishes. When the counter reaches zero, the task is eligible to run. Complexity is O(V+E) for building the graph and O(V+E) for scheduling, where V is the number of tasks and E the number of dependency edges. This approach scales to hundreds of tasks and ensures deterministic execution.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.

Get Assisting AI — Starts at ₹500