Greedy algorithms make locally optimal choices at each step in the hope of finding a globally optimal solution. The activity selection problem involves choosing a maximum set of activities that do not overlap in time. The greedy algorithm for this problem sorts activities by finish time and selects the earliest finishing activity at each step. This algorithm is optimal because the activity selection problem exhibits the optimal substructure property and the greedy algorithm satisfies the greedy-choice property at each step.