Dynamic programming on a ring of processors