Exam 2 Questions.pdf

3 problem 3 dynamic programming suppose a friend of

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

View Full Document Right Arrow Icon
3
Image of page 3

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

View Full Document Right Arrow Icon
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
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern