Activity Selection Visualization

The Activity Selection problem is a classic greedy algorithm problem. The goal is to select the maximum number of non-overlapping activities from a set, always picking the next activity that finishes earliest.

How Activity Selection Works

  1. Sort all activities by their finish time.
  2. Select the first activity (with the earliest finish time).
  3. For each subsequent activity, if its start time is after or equal to the finish time of the last selected activity, select it (cyan).
  4. Repeat until all activities are considered.

Cyan: Selected activity  | Yellow: Current activity