Application of job sequencing

Home / Design and Analysis of Algorithms(DAA)-Tutorial / DAA- Job Sequencing With Deadlines

Job Sequencing With Deadlines

Here is the process of Job sequencing in brief.

The problem states-

Approach to Solution

Greedy Algorithm Approach-

We adopt the greedy algorithm inorder to determine the selection of the next job to get an optimal solution.

Below is the greedy algorithm that is always supposed to give an optimal solution to the job sequencing problem.

Step-01:
Step-02:
Step-03:

Algorithm for Job Sequencing with Deadline:

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

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

PROBLEM BASED ON JOB SEQUENCING WITH DEADLINES-

Problem-

We are given the jobs, their deadlines and associated profits as shown-

JobsJ1J2J3J4J5J6
Deadlines 5 3 3 2 4 2
Profits 201 181 191 301 121 101

Answer the following questions-

  1. Write the optimal schedule that provides us the maximum profit.
  2. Can we complete all the jobs in the optimal schedule?
  3. What is the maximum earned profit?

Solution:

Step-01:

Firstly, we need to sort all the given jobs in decreasing order of their profit as follows.

JobsJ4J1J3J2J5J6
Deadlines 2 5 3 3 4 2
Profits 300 200 190 180 120 100

Step-02:

For each step, we calculate the value of the maximum deadline.

Here, the value of the maximum deadline is 5.

So, we draw a Gantt chart as follows and assign it with a maximum time on the Gantt chart with 5 units as shown below.

Step-03:

Step-04:

Step-05:

Step-06:

Step-07:

Now, the questions given above can be answered as follows:

Part-01:

The optimal schedule is-

Job2, Job4, Job3, Job5, Job1

In order to obtain the maximum profit this is the required order in which the jobs must be completed.

Part-02:

Part-03:

Maximum earned profit = Sum of the profit of all the jobs from the optimal schedule

= Profit of job2 + Profit of job4 + Profit of job3 + Profit of job5 + Profit of job1

= 181 + 301 + 191 + 121 + 201

Analysis of the algorithm:

In the job sequencing with deadlines algorithm, we make use of two loops, one loop within another. Hence, the complexity of this algorithm would be O(n2).

Register – Python Boot Camp

Design and Analysis of Algorithms(DAA)-Tutorial

Recent Posts

AI Increases innovation rate by 2021
Why Developers Are Turning to TypeScript for AI Development
The Reality of AI: Distinguishing Hype from Science
Generative AI’s House of Cards: How Synthetic Content Could Lead to ‘Model Collapse’
How Generative AI is Fueling Demand for Kubernetes

Top Tutorials