Gary C.

asked • 04/04/25

A dynamic programming question...


<< Ana needs to work on her algorithms homework, but the weather is getting nicer outside, so she also wants to spend more time outside.

Ana enjoys being outside more when

the weather is warmer: specifically, if the temperature outside is l (integer) units above zero,

Ana's happiness will increase by t after spending the day outside. (If L is negative, her happiness decreases.) On each of the n days until the homework is due, Ana will decide to either study or go outside (never both on the same day). To stay caught up with coursework, Ana creates a rule for herself that she will never go more than two days in a row without studying.

Given a weather forecast predicting the temperature 41, 2,..,In for the next n days, describe a worst-case On)-time dynamic programming algorithm to determine Ana's maximum possible happiness at the end of the n days. Briefly analyze your algorithm's running time.>>


Gary C.

Excellent. Thank you!!
Report

04/18/25

1 Expert Answer

By:

Ralph W. answered • 04/18/25

Tutor
4.9 (144)

To learn is to win, be a winner with me

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.