Find the Critical Path of a Nightly Mainframe Batch Schedule

Last updated: November 29, 2026

Quick Overview

Given batch jobs with durations and upstream dependencies, compute the earliest time the whole nightly run can finish with unlimited parallel slots, and return the chain of jobs that determines that time. Report an error if the dependencies contain a cycle.

Cognizant
Coding & Algorithms
Software Engineer
Cognizant
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given batch jobs with durations and upstream dependencies, compute the earliest time the whole nightly run can finish with unlimited parallel slots, and return the chain of jobs that determines that time. Report an error if the dependencies contain a cycle.

Cognizant runs many mainframe modernization programs where JCL batch chains are rebuilt as orchestrated jobs on cloud schedulers, and the first question is always whether the new run fits the batch window. This tests topological sorting, longest path in a DAG, and cycle detection with a clear error.

What the Interviewer Expects
  • Builds the graph and in-degree map, validating unknown dependencies
  • Uses Kahn's algorithm so cycles are detected by leftover nodes
  • Computes each job's start as the max finish of its parents
  • Tracks the parent that set the start to reconstruct the critical path
  • Explains O(V + E) cost
Key Topics to Cover
topological sort
DAG longest path
cycle detection
batch scheduling
critical path method
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Only 3 jobs can run at once. Is the problem still easy? What heuristic would you use?
  • How would you compute slack for every job, so the team knows which jobs can slip?
  • A job's duration varies night to night. How would you estimate the probability of missing the window?
  • How would you rerun only the downstream jobs after one job fails?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: jobs maps a name to (duration, [upstream names]). Every job starts once all upstream jobs finish; parallelism is unlimited. Output: the makespan (latest finish) and the critical path (the d...

High-Level Design

Run Kahn's algorithm. Each job's start is the maximum finish time among its parents; its finish is start plus duration. When a parent raises a child's start, record that parent as the child's critical...


Submit Your Answer
Markdown supported

Related Questions