R
robertday5
Need help in finding an efficient algorithm for the following problem.
There are tasks which have predecessor tasks which needs to be
completed before taking up the new task.
Our aim is to find the required order of the tasks, so that the
pre-requisite tasks are always completed before the task.
For example
TaskA needs taskJ and taskK
TaskB needs none
TaskC needs TaskA, taskK
taskD needs taskB
taskJ needs taskB
taskK needs none
There is no cyclical dependency and all the tasks take same amount of
time
A valid answer can be
taskB
taskK
taskJ
taskD
taskC
taskA
There are tasks which have predecessor tasks which needs to be
completed before taking up the new task.
Our aim is to find the required order of the tasks, so that the
pre-requisite tasks are always completed before the task.
For example
TaskA needs taskJ and taskK
TaskB needs none
TaskC needs TaskA, taskK
taskD needs taskB
taskJ needs taskB
taskK needs none
There is no cyclical dependency and all the tasks take same amount of
time
A valid answer can be
taskB
taskK
taskJ
taskD
taskC
taskA