JOB
SEQUENCING
1
Presented by: Rabin BK
BSc.CSIT 5th Semester
 Introduction
 Algorithm
 Example
 References
2
Introduction
3
 The objective is to find a sequence of jobs, which is completed within
their deadlines with maximum profit
 Because we are using two loops one within another, the complexity of
this algorithm is O(n2)
Algorithm
4
Algorithm Job_seq (d, 1, n){
d [0] = 0;
JS [1] = 1;
i = 1;
for j= 2 to n do;{
k = i;
while ((d[JS[k] > d[j]]) and (d[JS[k]] != k)) do
k = k -1;
if ((d[JS[k] < d[j]]) and (d[j] > k)) then {
For m= i to (k+1) step-1 do
JS [m+1] = JS [m];
JS [K+1] = j;
i = i+1;
}
}
Return i;
}
1
1
1
n
1
2*n
2
2*n
n*n
1*n*n
1*n*n
2*n*n
Time complexity = O(n2)
Example
5
Value of maximum deadline = 5
• First, we take job J4.
• Since, its deadline is 2, so we
place it in the first empty cell
before deadline 2 as-
• Now, we take job J1.
• Since, its deadline is 5, so we
place it in the first empty cell
before deadline 5 as-
• Now, we take job J3.
• Since, its deadline is 3, so we
place it in the first empty cell
before deadline 3 as-
Example
6
Value of maximum deadline = 5
• Now, we take job J2.
• Since, its deadline is 3, so we
place it in the first empty cell
before deadline 3.
• Since, the second and third cells
are already filled, so we place job
J2 in the first cell as-
• Now, we take job J5.
• Since, its deadline is 4, so we
place it in the first empty cell
before deadline 4 as-
• The only job left is job J6 whose deadline is 2.
• All the slots before deadline 2 are already occupied.
• Thus, job J6 can not be completed.
• Maximum earned profit = Sum of profits of all jobs in optimal schedule
= Profit of job J2 + Profit of job J4 + Profit of job J3 + Profit of job J5 +
Profit of job J1
= 180 + 300 + 190 + 120 + 200
= 990 units
References
• https://www.gatevidyalay.com/job-sequencing-with-deadlines/
• https://www.includehelp.com/operating-systems/job-sequencing.aspx
• https://www.geeksforgeeks.org/job-sequencing-problem-set-1-greedy-algorithm/
• http://www.cs.sfu.ca/~kabanets/307/sched307.pdf
• https://www.techiedelight.com/job-sequencing-problem-deadlines/
• http://ggn.dronacharya.info/CSEDept/Downloads/QuestionBank/Even/VI%20sem/
ADA/Section-B/job-scheduling1.pdf
• http://www.ques10.com/p/9083/write-short-notes-on-job-sequencing-with-
deadlines/
7
Queries
8

Job sequencing in Data Strcture

  • 1.
    JOB SEQUENCING 1 Presented by: RabinBK BSc.CSIT 5th Semester
  • 2.
     Introduction  Algorithm Example  References 2
  • 3.
    Introduction 3  The objectiveis to find a sequence of jobs, which is completed within their deadlines with maximum profit  Because we are using two loops one within another, the complexity of this algorithm is O(n2)
  • 4.
    Algorithm 4 Algorithm Job_seq (d,1, n){ d [0] = 0; JS [1] = 1; i = 1; for j= 2 to n do;{ k = i; while ((d[JS[k] > d[j]]) and (d[JS[k]] != k)) do k = k -1; if ((d[JS[k] < d[j]]) and (d[j] > k)) then { For m= i to (k+1) step-1 do JS [m+1] = JS [m]; JS [K+1] = j; i = i+1; } } Return i; } 1 1 1 n 1 2*n 2 2*n n*n 1*n*n 1*n*n 2*n*n Time complexity = O(n2)
  • 5.
    Example 5 Value of maximumdeadline = 5 • First, we take job J4. • Since, its deadline is 2, so we place it in the first empty cell before deadline 2 as- • Now, we take job J1. • Since, its deadline is 5, so we place it in the first empty cell before deadline 5 as- • Now, we take job J3. • Since, its deadline is 3, so we place it in the first empty cell before deadline 3 as-
  • 6.
    Example 6 Value of maximumdeadline = 5 • Now, we take job J2. • Since, its deadline is 3, so we place it in the first empty cell before deadline 3. • Since, the second and third cells are already filled, so we place job J2 in the first cell as- • Now, we take job J5. • Since, its deadline is 4, so we place it in the first empty cell before deadline 4 as- • The only job left is job J6 whose deadline is 2. • All the slots before deadline 2 are already occupied. • Thus, job J6 can not be completed. • Maximum earned profit = Sum of profits of all jobs in optimal schedule = Profit of job J2 + Profit of job J4 + Profit of job J3 + Profit of job J5 + Profit of job J1 = 180 + 300 + 190 + 120 + 200 = 990 units
  • 7.
    References • https://www.gatevidyalay.com/job-sequencing-with-deadlines/ • https://www.includehelp.com/operating-systems/job-sequencing.aspx •https://www.geeksforgeeks.org/job-sequencing-problem-set-1-greedy-algorithm/ • http://www.cs.sfu.ca/~kabanets/307/sched307.pdf • https://www.techiedelight.com/job-sequencing-problem-deadlines/ • http://ggn.dronacharya.info/CSEDept/Downloads/QuestionBank/Even/VI%20sem/ ADA/Section-B/job-scheduling1.pdf • http://www.ques10.com/p/9083/write-short-notes-on-job-sequencing-with- deadlines/ 7
  • 8.