Given an auditorium and a set of presentations, schedule the maximum
number of presentations possible.
Each presentation has a start and end time.
Each presentation requires exclusive use of the auditorium.
Exhaustive Search
Look at every possible schedule.
schedule(presentations)
schedlue = { }
for i = 1 to 2size(presentations) - 1
s = get-schedue(i, presentations)
if valid(s) ∧ size(s) > size(schedule)
schedule = s
return schedule
Faster Scheduling
Exhaustive search works if you don't schedule a lot of presentations
often.
But what if you do?
Is there an alternative scheduling algoritm faster than exhaustive
search?
An Alterntive Scheduler
Order the presentations by increasing finish time.
Scan the ordered presentations by increasing finish time.
Always schedule the next earliest finishing non-conflicting
presentation.
Does It Work?
Is the schedule S maximal?
Suppose schedule S' has more presentations.
Consider the first presentation in S and S'.
1 in S must end no later than 1' in S'.
Replace 1' in S' with 1.
Does It Work??
Schedules S and S' both agree on the first presentation.
Remove it from both schedules.
The remaining schedules must still be maximal.
Otherwise the original schedules weren't maximal.
Repeat the argument with the newly dimished schedules.
Does It Work???
The two schedules always agree on the first presentation.
The remaining schedules are always maximal.
The two schedules must have the same number of elements.