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 A1,, 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 1: Sort the activities according to their start times such that s1<= s2<=<= sn.
Consider activities A1, A2, An in this order, and schedule Ai to the room if it does not overlap with any class already scheduled.
Algorithm 2: Sort the activities according to their finishing times such that f1<= f2<=<=fn. Consider activities A1, A2, 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!