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