0% found this document useful (0 votes)
16 views3 pages

10 Job Sequencing With Deadline

The job sequencing problem aims to maximize profit by scheduling jobs within their deadlines. An algorithm is presented that sorts jobs by profit and selects them based on their deadlines, resulting in an optimal sequence. For the given example, the jobs J2, J1, and J3 are selected, yielding a total profit of 180.

Uploaded by

banmustafa66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

10 Job Sequencing With Deadline

The job sequencing problem aims to maximize profit by scheduling jobs within their deadlines. An algorithm is presented that sorts jobs by profit and selects them based on their deadlines, resulting in an optimal sequence. For the given example, the jobs J2, J1, and J3 are selected, yielding a total profit of 180.

Uploaded by

banmustafa66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DAA - Job Sequencing with Deadline

Problem Statement

In job sequencing problem, the objective is to find a sequence of jobs, which is


completed within their deadlines and gives maximum profit.

Solution

Let us consider, a set of n given jobs which are associated with deadlines and
profit is earned, if a job is completed by its deadline. These jobs need to be
ordered in such a way that there is maximum profit.

It may happen that all of the given jobs may not be completed within their
deadlines.
Assume, deadline of ith job Ji is di and the profit received from this job is pi.
Hence, the optimal solution of this algorithm is a feasible solution with maximum
profit.

Thus, D
D((i
i)) >
> 0
0 for 1
1 ⩽
⩽ i
i ⩽
⩽ n
n .

Initially, these jobs are ordered according to profit, i.e.


p
p1 ⩾ p2 ⩾
1 ⩾ p2 ⩾ p
p3 ⩾ . . . ⩾ pn
3 ⩾ . . . ⩾ pn
.

Algorithm: Job-Sequencing-With-Deadline (D, J, n, k)


D(0) := J(0) := 0
k := 1
J(1) := 1 // means first job is selected
for i = 2 … n do
r := k
while D(J(r)) > D(i) and D(J(r)) ≠ r do
r := r – 1
if D(J(r)) ≤ D(i) and D(i) > r then
for l = k … r + 1 by -1 do
J(l + 1) := J(l)
J(r + 1) := i
k := k + 1

Analysis
In this algorithm, we are using two loops, one is within another. Hence, the

complexity of this algorithm is O


O((n
2
2
n )
) .

Example

Let us consider a set of given jobs as shown in the following table. We have to
find a sequence of jobs, which will be completed within their deadlines and will
give maximum profit. Each job is associated with a deadline and profit.

Job J1 J2 J3 J4 J5

Deadline 2 1 3 2 1

Profit 60 100 20 40 20

Solution
To solve this problem, the given jobs are sorted according to their profit in a
descending order. Hence, after sorting, the jobs are ordered as shown in the
following table.

Job J2 J1 J4 J3 J5

Deadline 1 2 2 3 1

Profit 100 60 40 20 20

From this set of jobs, first we select J2, as it can be completed within its deadline
and contributes maximum profit.
Next, J1 is selected as it gives more profit compared to J4.
In the next clock, J4 cannot be selected as its deadline is over, hence J3
is selected as it executes within its deadline.
The job J5 is discarded as it cannot be executed within its deadline.
Thus, the solution is the sequence of jobs (J2, J1, J3), which are being executed
within their deadline and gives maximum profit.

Total profit of this sequence is 100 + 60 + 20 = 180.

You might also like