(Latest Revision:
Nov 02, 2021)
SOLUTION TO:
CS 4440 Practice Exercise
Interval Scheduling and Interval Partitioning Problems
The Given Intervals
(03, 06)
(01, 12)
(14, 22)
(28, 31)
(08, 24)
(13, 20)
(26, 29)
(10, 19)
(17, 26)
(23, 27)
(18, 25)
(04, 11)
(09, 16)
(02, 05)
Here is the same list of intervals (stably) sorted by increasing finish time:
(02, 05)
(03, 06)
(04, 11)
(01, 12)
(09, 16)
(10, 19)
(13, 20)
(14, 22)
(08, 24)
(18, 25)
(17, 26)
(23, 27)
(26, 29)
(28, 31)
Here is the list with letters next to the intervals chosen by the "Scheduling Intervals" algorithm:
(02, 05) A
(03, 06)
(04, 11)
(01, 12)
(09, 16) B
(10, 19)
(13, 20)
(14, 22)
(08, 24)
(18, 25) C
(17, 26)
(23, 27)
(26, 29) D
(28, 31)
Here is the same list of intervals (stably) sorted by increasing start time:
(01, 12)
(02, 05)
(03, 06)
(04, 11)
(08, 24)
(09, 16)
(10, 19)
(13, 20)
(14, 22)
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Solution Chosen by the Interval Partitioning Algorithm:
Classroom A: (01, 12) (14, 22) (28, 31)
Classroom B: (02, 05) (08, 24)
Classroom C: (03, 06) (09, 16) (17, 26)
Classroom D: (04, 11) (13, 20) (26, 29)
Classroom E: (10, 19) (23, 27)
Classroom F: (18, 25)
Interval Partitioning Work
(01, 12) X
(02, 05)
(03, 06)
(04, 11)
(08, 24)
(09, 16)
(10, 19)
(13, 20)
(14, 22)
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom A: (01, 12) <== PQ Top
(01, 12) X
(02, 05) X
(03, 06)
(04, 11)
(08, 24)
(09, 16)
(10, 19)
(13, 20)
(14, 22)
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom B: (02, 05) <== PQ Top (We know this second interval starts no earlier than any interval in Classroom A, and so the test 2<12, tells us that (02,5) conflicts with Classroom A.)
Classroom A: (01, 12)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11)
(08, 24)
(09, 16)
(10, 19)
(13, 20)
(14, 22)
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom B: (02, 05) <== PQ Top (We only had to check B (the test 3<5) to know neither A nor B is compatible with (03, 06). This third interval starts no earlier than any interval in A or B, and the test tells us that the third interval starts before any of the others finishes.)
Classroom C: (03, 06)
Classroom A: (01, 12)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24)
(09, 16)
(10, 19)
(13, 20)
(14, 22)
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom B: (02, 05) <== PQ Top (We only had to check B to know neither A, B nor C is compatible with (04, 11))
Classroom C: (03, 06)
Classroom D: (04, 11)
Classroom A: (01, 12)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16)
(10, 19)
(13, 20)
(14, 22)
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom C: (03, 06) <== PQ Top
Classroom D: (04, 11)
Classroom A: (01, 12)
Classroom B: (02, 05) (08,24)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16) X
(10, 19)
(13, 20)
(14, 22)
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom D: (04, 11) <== PQ Top
Classroom A: (01, 12)
Classroom C: (03, 06) (09, 16)
Classroom B: (02, 05) (08,24)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16) X
(10, 19) X
(13, 20)
(14, 22)
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom D: (04, 11) <== PQ Top (We only had to check D to know that (10,19) was not compatible with A, B, C, or D))
Classroom A: (01, 12)
Classroom C: (03, 06) (09, 16)
Classroom E: (10, 19)
Classroom B: (02, 05) (08,24)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16) X
(10, 19) X
(13, 20) X
(14, 22)
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom A: (01, 12) <== PQ Top
Classroom C: (03, 06) (09, 16)
Classroom E: (10, 19)
Classroom D: (04, 11) (13, 20)
Classroom B: (02, 05) (08, 24)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16) X
(10, 19) X
(13, 20) X
(14, 22) X
(17, 26)
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom C: (03, 06) (09, 16) <== PQ Top
Classroom E: (10, 19)
Classroom D: (04, 11) (13, 20)
Classroom A: (01, 12) (14, 22)
Classroom B: (02, 05) (08, 24)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16) X
(10, 19) X
(13, 20) X
(14, 22) X
(17, 26) X
(18, 25)
(23, 27)
(26, 29)
(28, 31)
Classroom E: (10, 19) <== PQ Top
Classroom D: (04, 11) (13, 20)
Classroom A: (01, 12) (14, 22)
Classroom B: (02, 05) (08, 24)
Classroom C: (03, 06) (09, 16) (17, 26)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16) X
(10, 19) X
(13, 20) X
(14, 22) X
(17, 26) X
(18, 25) X
(23, 27)
(26, 29)
(28, 31)
Classroom E: (10, 19) <== PQ Top
Classroom D: (04, 11) (13, 20)
Classroom A: (01, 12) (14, 22)
Classroom B: (02, 05) (08, 24)
Classroom F: (18, 25)
Classroom C: (03, 06) (09, 16) (17, 26)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16) X
(10, 19) X
(13, 20) X
(14, 22) X
(17, 26) X
(18, 25) X
(23, 27) X
(26, 29)
(28, 31)
Classroom D: (04, 11) (13, 20) <== PQ Top
Classroom A: (01, 12) (14, 22)
Classroom B: (02, 05) (08, 24)
Classroom F: (18, 25)
Classroom C: (03, 06) (09, 16) (17, 26)
Classroom E: (10, 19) (23, 27)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16) X
(10, 19) X
(13, 20) X
(14, 22) X
(17, 26) X
(18, 25) X
(23, 27) X
(26, 29) X
(28, 31)
Classroom A: (01, 12) (14, 22) <== PQ Top
Classroom B: (02, 05) (08, 24)
Classroom F: (18, 25)
Classroom C: (03, 06) (09, 16) (17, 26)
Classroom E: (10, 19) (23, 27)
Classroom D: (04, 11) (13, 20) (26, 29)
(01, 12) X
(02, 05) X
(03, 06) X
(04, 11) X
(08, 24) X
(09, 16) X
(10, 19) X
(13, 20) X
(14, 22) X
(17, 26) X
(18, 25) X
(23, 27) X
(26, 29) X
(28, 31) X
Classroom B: (02, 05) (08, 24) <== PQ Top
Classroom F: (18, 25)
Classroom C: (03, 06) (09, 16) (17, 26)
Classroom E: (10, 19) (23, 27)
Classroom D: (04, 11) (13, 20) (26, 29)
Classroom A: (01, 12) (14, 22) (28, 31)
After putting the solution into alphabetical order, instead of priority order:
Classroom A: (01, 12) (14, 22) (28, 31)
Classroom B: (02, 05) (08, 24) <== PQ Top
Classroom C: (03, 06) (09, 16) (17, 26)
Classroom D: (04, 11) (13, 20) (26, 29)
Classroom E: (10, 19) (23, 27)
Classroom F: (18, 25)