Rod Cutting Algorithm