Exam 2 Questions.pdf

3 problem 3 dynamic programming suppose a friend of

This preview shows pages 3–5. Sign up to view the full content.

3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Problem 3: Dynamic Programming Suppose a friend of yours is planning to attend a workout program to lose weight. Each day he has to choose an exercise. The set of possible exercises is divided into those that are low-level and those that are high-level. The basic question each day is whether to choose a low or high level exercise. If he selects a low-level exercise on day i , then he burns l i > 0 calories; if he selects a high-level exercise he burns h i > 0 calories. However, if he does high level activity on one day, it is required that he cannot choose any exercise on the next day. He has to rest. On the other hand, if he does a low-level exercise on one day, it is okay for him to select either type of exercise on the next day. A plan is a list of choices of “low-level”, “high-level” or “none” given a se- quence of n days, with the condition that if “high-level” is chosen on a day i > 0 then “none” has to be chosen for day i + 1. Your friend can start with any choice on day 1. The value of the plan is the total calories he burns at the end of n days. Design a dynamic programming algorithm that takes values for l 1 , l 2 , ...l n and h 1 , h 2 , ...h n and returns the plan of maximum calories. (Hint: Draw the DAG corresponding to this problem.) 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern