Question: You are given n classes A 1 , , An such that each Ai is associated with [ si , fi ] where si and
You are given n classes A An such that each Ai
is associated with si fi where si and fi denote the start and the finishing time of Ai You are to select the maximum number of classes that can be scheduled in a single classroom such that no two activities
can be scheduled unless they do not have an overlapping period. Consider the following two
algorithms. Only one of them produces an optimal solution. For each algorithm, prove its
correctness or give a counter example to disprove it
Algorithm : Sort the activities according to their start times such that s s sn
Consider activities A A An in this order, and schedule Ai to the room if it does not overlap with any class already scheduled.
Algorithm : Sort the activities according to their finishing times such that f ffn Consider activities A A An in this order, and schedule Ai to the room if it does not overlap with any class already scheduled.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
