- S = {1, 2, .., n} proposed activities
- All want the same resource (classroom), used by one at a time
- Each activity i has start time
*s*_{i}and finish time*f*_{i}, , [*s*_{i},*f*_{i}) - Two activities i and j are compatible if they do not overlap ( or )

**Problem:** Select maximum-size set of compatible activities.
Assume the input is sorted by
(O(nlgn)).

**Greedy algorithm:**

Greedy-AS(s, f)

1
n = length(s)

2
A = {1}
; Initialize A

3
j = 1

4
for i = 2 to n

5
if
; Compatible

6
then A = A {i}

7
j = i

8
return A