Activity Selection Problem and a “Last-Start” Greedy Strategy
The activity selection problem is a classic optimization problem on intervals. Each activity has a start time and finish time with . Two activities are compatible if they do not overlap, i.e., for activities and with (equivalently, one finishes before the other starts).
A standard greedy strategy chooses the activity with the earliest finish time among those that are compatible with what you have already chosen. The variant you asked about uses a “reverse” viewpoint:
Instead of selecting the first compatible activity to finish, select the last activity to start that is compatible with all previously selected activities.
This “last-start compatible” rule is also a greedy algorithm, and it can be proven optimal by an exchange argument using interval ordering properties.
Key terms: compatible activities , greedy-choice property , exchange argument , optimal substructure.
Activity Selection Problem (Greedy Algorithm)
Formal problem statement
Let the set of activities be . Activity is the closed-open interval (any consistent overlap convention works). We want a maximum-size subset such that for any two activities , they do not overlap: if precedes then .
A greedy algorithm repeatedly extends a partial solution by choosing a single “best” activity according to some local rule, without reconsidering earlier choices.
In the last-start compatible strategy, we proceed like this:
- Maintain the already selected set (initially empty).
- Among activities that are compatible with all already-selected ones, choose the activity with the largest start time.
- Add it to the set.
- Repeat on the remaining activities that are compatible with the augmented set.
To make implementation and reasoning clean, we typically order activities by finish time (or by start time depending on the proof). For the last-start strategy, ordering by start time is intuitive, but the proof can be framed using finish times to preserve the non-overlap structure.
Key terms: interval ordering , selection subset , feasible solution , maximal cardinality.
Last-Start-Compatible Greedy Algorithm (Reverse selection)
- 1Step 1
Maintain a set S of chosen activities. An activity a is compatible with S if it does not overlap any activity in S; under a chosen ordering of S, this reduces to checking that its finish time is <= the next selected start time.
- 2Step 2
Among all activities compatible with S, pick the activity with the largest start time. (Equivalently: pick the “rightmost” activity that still fits before the already-chosen boundary.)
- 3Step 3
After selecting activity a, update the boundary to the selected activity's start time. Only activities that finish no later than that boundary can remain compatible.
- 4Step 4
When no remaining activity can be added without overlapping S, stop. The resulting S is the output.
- 5Step 5
S contains a feasible subset. The proof below shows its size is maximal.
Why this is a greedy algorithm
By construction, at each step the algorithm makes a single local decision: it chooses the compatible activity with the largest start time and never revisits that choice.
Formally, let be the set selected after iterations. The -st iteration picks an activity that:
- is compatible with , and
- maximizes among such compatible candidates.
This is the hallmark of the greedy paradigm: a local optimization criterion that determines the next element of the solution.
Key terms: greedy choice , partial solution , iteration invariant.
Correctness proof (optimality via exchange argument)
We prove that the “last-start compatible” greedy strategy yields an optimal solution (maximum number of non-overlapping activities).
Setup and ordering
Let the activities be distinct or ties handled consistently. Sort activities by start times decreasing (so “last to start” means highest start time).
At any stage, the already selected activities form a feasible schedule. Let the “current boundary” be the earliest start time among activities already selected (because we are building backward: we pick an activity that must end before the boundary starts, so it can fit without overlapping what is already selected).
Define a subproblem: given a boundary time , consider only activities that finish at or before :
Then the goal is to select the maximum number of pairwise non-overlapping activities from .
The greedy rule chooses, from , the activity with the largest start time:
After choosing , we update the boundary to , because any additional activity must end before the start of the newly chosen one.
Thus, the algorithm is recursively:
- pick ,
- then solve the subproblem with boundary .
Lemma (greedy-choice property)
Lemma: There exists an optimal solution for subproblem that includes the greedy choice .
Proof (exchange argument): Let be an optimal solution for . If , we are done.
Otherwise, . Consider the activity that is the first activity in (in the backward sense) that conflicts with or, equivalently, the activity in with the largest start time among those that are compatible to the same extent. A more direct interval argument works:
- Since both and activities in are feasible within , every activity in must lie in time positions that do not overlap each other, and they all finish by .
- Let be the activity in with the largest start time among those in . Because is a set of non-overlapping intervals within , these intervals have an induced order.
- Compare with . By definition of , we have .
- Replace with in to form a new set: We claim is feasible and has the same cardinality.
Feasibility reasoning: because has the latest start among all activities that finish by , and because was the latest-start interval in , swapping in cannot create overlap with activities earlier in the schedule (they all end the start boundary imposed by the later activity), and also finishes by so it does not overlap the later-than- region (none exists). Therefore, all non-overlap constraints remain satisfied.
Thus, is feasible, has , and includes . Hence, there exists an optimal solution that contains the greedy choice.
Theorem (global optimality)
The greedy algorithm is optimal: the solution it outputs has maximum possible size.
Proof (induction on the number of activities / subproblem boundary): We prove by induction on the “size” of the subproblem (e.g., number of candidate activities).
- Base case: If is empty or contains only one activity, the greedy algorithm is trivially optimal.
- Inductive step: Assume the algorithm is optimal for all smaller subproblems (with earlier boundaries). Consider subproblem .
- By the Lemma, there exists an optimal solution that includes the greedy activity .
- After selecting , the remaining activities must all lie in the subproblem with boundary .
- The greedy algorithm then solves this subproblem optimally by the induction hypothesis.
- Therefore, combining with the optimal remaining solution produces an optimal solution for .
Hence, by induction, the greedy algorithm yields a globally optimal maximum-size feasible set.
Key terms: subproblem boundary , induction on subproblems , feasibility preserved.
type="tip" title="How to remember the proof idea" content="Both earliest-finish and last-start versions work because you can show: (1) a greedy choice can be forced into some optimal solution via exchange, then (2) the remainder is an independent smaller subproblem (optimal substructure)."
type="warning" title="Common proof pitfall" content="If you define the “boundary” incorrectly (e.g., using finish time instead of the correct start boundary when building backward), the exchange step may no longer preserve feasibility. Always align the boundary with the direction you’re selecting."
Greedy selection flow (backward construction)
Start with an empty schedule
T = +∞ (conceptual)No activities chosen; all activities finishing by T are available."
Pick activity with last start time
Step 1Choose with the maximum among those with ."
Set $T \leftarrow s_{g(T)}$
Update boundaryOnly activities that finish before the chosen activity starts remain compatible."
Continue until no candidate remains
RepeatThe accumulated set is maximum-size by the correctness proof."
Greedy rule comparison (conceptual)
Both strategies are greedy but choose different local “best” elements.
Common questions
Activity Selection — Greedy Proof Essentials
Knowledge Check
In the last-start compatible greedy algorithm, what is the local choice at each step?