Value max(FindOptimalPlanValue
if n == 1 then
Value max(l[n], h[n])
else if n == 2 then
Value max(FindOptimalPlanValue(1, l, h)+ l[2], h[2])
else
Value max(FindOptimalPlanValue(n − 1, l, h) + l[n],FindOptimalPlanValue(n − 2, l, h) + h[n])
end if
return Value
FindOptimalValue(n, l, h)
Initialization:
for i = 1 ! n do
Value[i] = 0
end for
for i = 1 ! n do
if i == 1 then
Value[i] max(l[i], h[i])
else if i == 2 then
Value[i] max(Value[1] + l[2], h[2])
else
Value[i] max(Value[i − 1] + l[i], Value[i − 2] + h[i])
end if
end for
return Value[n]
FindOptimalPlan(n, l, h, Value)
Initialization:
for i = 1 ! n do
Weeks[i] "Do nothing"
end for
if Value[n] − l[n] = Value[n − 1] then
Weeks[n] "Low stress"
FindOptimalPlan(n-1, l, h, Value)
else
Weeks[n] "High stress"
FindOptimalPlan(n-2, l, h, Value)
end if
return Weeks
Â
Please provide me an executable program for the above code... The problem is present in Photo attached.
Answers
Status NEW
Posted 18 May 2017 04:05 AM
My Price 8.00
-----------
Not Rated(0)