Greedy Algorithms8 sections · 316 units
Open in Course

Trying the Example

Finding the answer

Activities: [(1,4), (3,5), (0,6), (5,7), (8,9), (5,9)]. One possible selection: (1,4), (5,7), (8,9). These do not overlap. Count: 33. Can you do better? Try other combinations.

Notice that (0,6) is long and blocks many others. Avoiding it might be better. After trying, you should find that 33 is the maximum. But how do you find this systematically? Trying all subsets takes 2n2^n time, too slow. You need a greedy strategy that works in polynomial time.