Greedy Algorithms8 sections · 316 units
Open in Course

Walkthrough

Tracing the algorithm

Activities: [(1,4), (3,5), (0,6), (5,7), (8,9), (5,9)]. Sorted by end time: [(1,4), (3,5), (0,6), (5,7), (5,9), (8,9)]. 1.1. Select (1,4). Last end = 44.

2.2. (3,5): start 33 < 44. Conflicts. Skip.

3.3. (0,6): start 00 < 44. Conflicts. Skip.

4.4. (5,7): start 55 >= 44. Select! Last end = 77.

5.5. (5,9): start 55 < 77. Conflicts. Skip.

6.6. (8,9): start 88 >= 77. Select! Last end = 99. Selected: (1,4), (5,7), (8,9). Count: 33. Notice each selection extends the timeline minimally.