Question: You aim to get outside as much as possible this summer. Your two favorite activities are hiking the White Mountains and going to the beach
You aim to get outside as much as possible this summer. Your two favorite activities are hiking the White Mountains and going to the beach on Cape Cod. Each weekend you chooose which of the two activites to partake in Hiking is your true favorite, but it is much more exhausting so if you go hiking one weekend, youll be too tired to get off of the couch the following one even to go the beach! You have your friends calendars and have looked at longrange weather forecast, and the goal is to decide each weekend whether to head to the mountains or hit the beach. On weekend i if you go hiking, you get value hi and if you go to the beach, you get value bi Recall, if you go hiking, then you cannot partake in either activity on weekend i Given a set of values hbhnbn for n weekends, a schedule is a set of choices for each of the n weekends, where each weekend you can either chose hikingbeach or none and if you choose hiking on weekend i then you must choose none on weekend i The value of a schedule is the sum of the values of the activities you choose each weekend.Your goal is to design a dynamic programming algorithm that takes as input the n values hbhnbn and computes an optimal schedule ie a schedule with maximum value
For example, if given the input:
Weekend Weekend Weekend Weekend
b
h
the optimal schedule would be to go to the beach on weekend hiking on weekends and and staying on the couch on weekend which has a value of
a Let OPTi be the maximum value you can get for doing the activities during weekends iin Give a recurrence to compute OPTi from the values OPTi OPTn and write the base cases for this recurrence. Write a few sentences explaining why your recurrence is correct.
b Using your recurrence, design a dynamic programming algorithm to output the optimal schedule of activities. You may use either a topdown or bottomup approach. Remember that your algorithm needs to output the optimal schedule, not only its value. The output to your algorithm can be an array of length n in which the ith entry gives the choice made for weekend i in the optimal schedule this choice is one of beachhikingcouch
c Analyze the running time and space usage of your algorithm.Problem
You aim to get outside as much as possible this summer: Your two favorite activities are hiking the White
Mountains and going to the beach on Cape Cod. Each weekend you chooose which of the two activites to partake
in Hiking is your true favorite, but it is much more exhausting, so if you go hiking one weekend, you'll be too
tired to get off of the couch the following one even to go the beach You have your friends' calendars and have
looked at longrange weather farecast, and the goal is to decide each weekend whether to head to the mountains
or hit the beach. On weekend if you go hiking, you get value and if you go to the beach, you get value
Recall, if you go hiking, then you cannot partake in either activity on weekend Given a set of values
for weekends, a schedule is a set of choices for each of the weekends, where each weekend you
can either chose "hiking", "beach", or "none", and if you choose "hiking" on weekend then you must choose
"none" on weekend The value of a schedule is the sum of the values of the activities you choose each
weekend.Xour goal is to design a dynamic programming algorithm that takes as input the values dots,
and computes an optimal schedule ie a schedule with maximum value
For example, if given the input:
the optimal schedule would be to go to the beach on weekend hiking on weekends and and staying on
the couch on weekend which has a value of
a Let OPT be the maximum value you can get for doing the activities during weekends Give a
recurrence to compute OPT from the values OPT and write the base cases for this
recurrence. Write a few sentences explaining why your recurrence is correct.
b Using your recurrence, design a dynamic programming algorithm to output the optimal schedule of
activities. You may use either a topdown or bottomup approach. Remember that your algorithm needs
to output the optimal schedule, not only its value. The output to your algorithm can be an array of length
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
