Reputation: 837
I have a number of jobs (J1, J2, ...)
and there priority (P1, P2, ...)
and based on there relative priority.
I have to schedule them in minimum number of steps
.
Example for 5 jobs with 4 rules
of relative priority:
P(J1) > P(J3)
P(J2) > P(J3)
P(J3) > P(J4)
P(J2) > P(J5)
Solution: P1, P2, P3, P4, P5
OR P1, P2, P3, P5, P4
There maybe more than one solution but the solution should confirm to above 4 rules.
Upvotes: 1
Views: 154
Reputation: 6379
You are looking for a topological sorting algorithm. Here you have a directed graph where the vertices are the jobs and there is an edge from A
to B
iff P(A) > P(B)
.
Upvotes: 3