You are on page 1of 20

4.

G REEDY A LGORITHMS

‣ earliest-finish-time-first algorithm demo

SECTION 2.1
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

0 1 2 3 4 5 6 7 8 9 10 11
2
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

job B is compatible (add to schedule)

B
0 1 2 3 4 5 6 7 8 9 10 11
3
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

B
0 1 2 3 4 5 6 7 8 9 10 11
4
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

job C is incompatible (do not add to schedule)

B C
0 1 2 3 4 5 6 7 8 9 10 11
5
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

B
0 1 2 3 4 5 6 7 8 9 10 11
6
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

job A is incompatible (do not add to schedule)

B A
0 1 2 3 4 5 6 7 8 9 10 11
7
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

B
0 1 2 3 4 5 6 7 8 9 10 11
8
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

job E is compatible (add to schedule)

B E
0 1 2 3 4 5 6 7 8 9 10 11
9
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

B E
0 1 2 3 4 5 6 7 8 9 10 11
10
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

job D is incompatible (do not add to schedule)

B D
E
0 1 2 3 4 5 6 7 8 9 10 11
11
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

B E
0 1 2 3 4 5 6 7 8 9 10 11
12
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

job F is incompatible (do not add to schedule)

B E F
0 1 2 3 4 5 6 7 8 9 10 11
13
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

B E
0 1 2 3 4 5 6 7 8 9 10 11
14
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

job G is incompatible (do not add to schedule)

B E
0 1 2 3 4 5 6 7 8 9 10 11
15
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

job G is incompatible (do not add to schedule)

B E G
0 1 2 3 4 5 6 7 8 9 10 11
16
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

B E
0 1 2 3 4 5 6 7 8 9 10 11
17
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

job H is compatible (add to schedule)

B E H
0 1 2 3 4 5 6 7 8 9 10 11
18
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

B E H
0 1 2 3 4 5 6 7 8 9 10 11
19
Earliest-finish-time-first algorithm demo

H
time
0 1 2 3 4 5 6 7 8 9 10 11

done (optimal set of jobs)

B E H
0 1 2 3 4 5 6 7 8 9 10 11
20

You might also like