单选题:In Activity Selection Problem, we are given a set of activities
In Activity Selection Problem, we are given a set of activities $$S=\{a_1, a_2, \ldots, a_n \}$$ that wish to use a resource (e.g. a room). Each $$a_i$$ takes place during a time interval $$[s_i, f_i)$$.
Let us consider the following problem: given the set of activities $$S$$, we must schedule them all using the minimum
number of rooms.
**Greedy1**:
Use the optimal algorithm for the Activity Selection Problem to find the max number of activities that can be scheduled in one room. Delete and repeat on the rest, until no activities left.
**Greedy2**:
* Sort activities by start time. Open room 1 for $$a_1$$.
* for $$i = 2$$ to $$n$$
if $$a_i$$ can fit in any open room, schedule it in that room;
otherwise open a new room for $$a_i$$.
Which of the following statement is correct?
@[C](3)
A. None of the above two greedy algorithms are optimal.
B. Greedy1 is an optimal algorithm and Greedy2 is not.
C. Greedy2 is an optimal algorithm and Greedy1 is not.
D. Both of the above two greedy algorithms are optimal.
A.None of the above two greedy algorithms are optimal.
B.Greedy1 is an optimal algorithm and Greedy2 is not.
C.Greedy2 is an optimal algorithm and Greedy1 is not.
D.Both of the above two greedy algorithms are optimal.
答案:C
Let us consider the following problem: given the set of activities $$S$$, we must schedule them all using the minimum
number of rooms.
**Greedy1**:
Use the optimal algorithm for the Activity Selection Problem to find the max number of activities that can be scheduled in one room. Delete and repeat on the rest, until no activities left.
**Greedy2**:
* Sort activities by start time. Open room 1 for $$a_1$$.
* for $$i = 2$$ to $$n$$
if $$a_i$$ can fit in any open room, schedule it in that room;
otherwise open a new room for $$a_i$$.
Which of the following statement is correct?
@[C](3)
A. None of the above two greedy algorithms are optimal.
B. Greedy1 is an optimal algorithm and Greedy2 is not.
C. Greedy2 is an optimal algorithm and Greedy1 is not.
D. Both of the above two greedy algorithms are optimal.
A.None of the above two greedy algorithms are optimal.
B.Greedy1 is an optimal algorithm and Greedy2 is not.
C.Greedy2 is an optimal algorithm and Greedy1 is not.
D.Both of the above two greedy algorithms are optimal.
答案:C