The greedy algorithm