A simulation of one possible offline algorithm.