33% found this document useful (3 votes)
3K views8 pages

Job Sequencing With Deadlines

The algorithm sorts jobs by non-increasing profit and assigns each job to the earliest available time slot that satisfies its deadline. It takes O(n log n) time to sort the jobs and O(n) time to assign slots, so the overall time complexity is O(n log n). The algorithm cannot be improved further as it already finds the optimal schedule in optimal time.

Uploaded by

sramsubbu
Copyright
© Attribution Non-Commercial (BY-NC)
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
33% found this document useful (3 votes)
3K views8 pages

Job Sequencing With Deadlines

The algorithm sorts jobs by non-increasing profit and assigns each job to the earliest available time slot that satisfies its deadline. It takes O(n log n) time to sort the jobs and O(n) time to assign slots, so the overall time complexity is O(n log n). The algorithm cannot be improved further as it already finds the optimal schedule in optimal time.

Uploaded by

sramsubbu
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 8

Consider a scheduling problem where the 6 jobs have a profit of (10,34,67,45,23,99) and corresponding

deadlines (2,3,1,4,5,3). Obtain the optimum schedule. What is the time complexity of your algorithm? Can
you improve it?

JOB SEQUENCING WITH DEADLINES ALGORITHM


SIMULATION
Ordering the jobs be nonincreasing order of profit:

Jobs = (99, 67, 45, 34, 23, 10)

Job No. =(6, 3, 4, 2, 5, 1)

Deadlines =(2, 3, 1, 4, 5, 3)

New job no. =(I, II, III. IV, V, VI)

Job I is allotted slot [0,1]

New Job no. I

Ordered by 2
deadlines

Job no. 6

Job II is allotted slot [1,2], the deadlines are in increasing length.

New Job no. I II

Ordered by 2 3
deadlines

Job no. 6 3

Job III is being considered. Deadline is 1, so we have to shift jobs I and II upward

New Job no. I II

Ordered by 2 3
deadlines

Job no. 6 3
New Job no. III I II

Ordered by 1 2 3
deadlines

Job no. 4 6 3

The deadlines are in increasing order.

New Job no. III I II

Ordered by 1 2 3
deadlines

Job no. 4 6 3

Job IV has a deadline of 4, so it can be allotted slot [3,4]

New Job no. III I II IV

Ordered by 1 2 3 4
deadlines

Job no. 4 6 3 2

Job V has a deadline of 5, so it can be allotted slot [4,5]

New Job no. III I II IV V

Ordered by 1 2 3 4 5
deadlines

Job no. 4 6 3 2 5

Job VI has a deadline of 3 but we cannot shift the array to the left, so we reject job VI.

The above is a the schedule.


FAST Job Sequencing with deadlines.

Consider a scheduling problem where the 6 jobs have a profit of (10,34,67,45,23,99) and
corresponding deadlines (2,3,1,4,5,3). Obtain the optimum schedule. What is the time
complexity of your algorithm? Can you improve it?

Sort jobs in nondecreasing order of profit:

Profits = (99, 67, 45, 34, 23, 10)


Job no. = ( 6, 3, 4, 2, 5, 1)
New no = ( I, II, III, IV, V, VI)
Deadline = (2, 3, 1, 4, 5, 3)

Start with all slots free.

[-1,0],free [0,1],free [1,2],free [2,3],free [3,4],free [4,5],free

-1 -1 -1 -1 -1 -1

Job I considered, do it in [1,2] slot which is free.

[-1,0],free [0,1],free [1,2],job I [2,3],free [3,4],free [4,5],free

-1 -1 -1 -1 -1 -1

Job II is considered, do it in [2,3] slot.


[-1,0],free [0,1],free [1,2],job I [2,3],jobII [3,4],free [4,5],free

-1 -1 -1 -1 -1 -1

Take Union of [1,2] and new [2,3] slot.

[-1,0],free [0,1],free [1,2],job I [3,4],free [4,5],free

-1 -1 -2 -1 -1

[2,3],jobII

Job III, considered.Deadline is 1. Allot [0,1] slot.

[-1,0],free [0,1],III [1,2],job I [3,4],free [4,5],free

-1 -1 -2 -1 -1

[2,3],jobII
Take union of [1,2] and new [0,1] slot.

[-1,0],free [1,2],job I [3,4],free [4,5],free

-1 -3 -1 -1

[2,3],jobII
[0,1],III

Consider job no IV. Deadline is 4, allot to [3,4] slot which is free.

[-1,0],free [1,2],job I [3,4], IV [4,5],free

-1 -3 -1 -1

[2,3],jobII
[0,1],III

Take union of [1,2] and [3,4] slot.


[-1,0],free [1,2],job I [4,5],free

-1 -4 -1

[3,4],IV

[2,3],jobII
[0,1],III

Job V has a deadline of 5, allot to [4,5] slot which is free.

[-1,0],free [1,2],job I [4,5],V

-1 -4 -1

[3,4],IV

[2,3],jobII
[0,1],III

Take union of [1,2] and [4,5] slot that has been created.
[-1,0],free [1,2],job I [4,5],V

-1 -5

[3,4],IV

[2,3],jobII
[0,1],III

Job VI considered now. It has a deadline of 3. No slot except [-1,0] is free, counting
down from [2,3]. So allot it to [-1,0] which is always free and means reject the job.

[-1,0],VI [1,2],job I [4,5],V

-1 -5

[3,4],IV

[2,3],jobII
[0,1],III
[-1,0],VI [1,2],job I [4,5],V

-6

[3,4],IV

[2,3],jobII
[0,1],III

ABOVE IS FINAL SCHEDULE.

You might also like