Data Processing Pipeline: n tasks — tasks have ids [0,1,2,…,n-1].
Task Ti depends on task Tj — [Ti, Tj] — task Ti cannot start unless task Tj has finished.
Example: n = 5 tasks — list of dependencies dlist = [[1,0], [2,0], [3,4], [3,1], [4,2]]
[1,0]— 1 depends on 0[2,0]— 2 depends on 0[3,4]— 3 depends on 4[3,1]— 3 depends on 1[4,2]— 4 depends on 2
Execution Order: 0 -> 1 / 2 -> 4 -> 3
This problem is a classic task-scheduling question with prerequisites. Model the tasks as a directed graph, build edges from each prerequisite to the dependent task, and use topological sorting to find a valid execution order. In the sample, task 0 must run first, tasks 1 and 2 can start after 0, task 4 depends on 2, and task 3 depends on both 1 and 4. Also watch for cycles, because a cycle means no valid schedule exists.