p
2 3
I
Is
I 5 Is
4
6 of
observation
i
Either job I is partof an or it isn’t
opt So l
O
to
rI 2IP2zO
isL IP6
past
5 TO
87.6
l
Cased case2
ICOj I Oj
OPT Ij opt i1
0PTG
l
constructing PC can bedone in 0dga tie using binary search
i4
oPT4
wit OPTCpcis
Rpt
a
A
Tca
1
Tcu z
Max d.yampnt
comput optcpciD optfj.is
Tnf
Tca exponentialfunction
f 1
z
tl
I
wj
O
n
n¦Ì
me I
Max
0
return
Define M Cj
M compute opt M compute opt
and if
wit pegs
ji
compkxityttnalya.is
Sortrequests create PC
n
0
OCn lga
M compak opt.io
OCnlgn
ooeralloompboity
urban
f
mis
OPT pci
j
OPT
It
on opt so IO
l
Computing
belongs Wj to PTCpci
Oj
to
iff
7 OPTOt
Eppes M
graffiti
o
Ocn
p
is
p
topd
Mfo owupassqjjiifimaxcm.in
takes
fF H
acpcio
Eo
A
m
choices i
Ii
B t.i.siO walk into thenextsquare
2 3H
jumpovertonesquare
costsounds a 150
two
in general we toedunitsofenergy
when we land on Square 1 Question How doyougohomesuch
that you lose a min amount of emergency in this process
y
c
i
35cg
opt n
opt level ofenergy
when we
reach square 2
OPT
pass OPTCn D
eudfe talus
y
es Ey
Imax
OPT n I OPT n 2
msn.it FET
IO LEO
EEO es Ahem
tf
me
OG
i
geico
E then on
if
ie O this
0PM
request L
a
0
OP
W
Wn OPTn lwWii
no
off
input anayoysign
We
ftak.de Ypseudffomil
wth t l l l pep
Im
complexity
TWrfwgwahitsnwesnzb9 nwss.a.sn
so
ee
in o
t knapsacks objecthas value Ui weight wi
Recurrence formula for
if otherwise
wi then
o I knapsack
OPTCi w
Max optLi l
w
OPTLi i w
opt ti w No
w
fit
0 PT i l w wi
Discussion 6
1. You are to compute the total number of ways to make a change for a given amount m. Assume that we have an unlimited supply of coins and all denominations are sorted in ascending order:1 = d1 < d2 < ... < dn . Formulate the solution to this problem as a dynamic programming problem.
2. Graduate students get a lot of free food at various events. Suppose you have a schedule of the next n days marked with those days when you get a free dinner, and those days on which you must acquire dinner on your own. On any given day you can buy dinner at the cafeteria for $3. Alternatively, you can purchase one week's groceries for $10, which will provide dinner for each day that week (that day and the six that follow). However, because you don't have a fridge, the groceries will go bad after seven days (including the day of purchase) and any leftovers must be discarded. Due to your very busy schedule, these are your only two options for dinner each night. Your goal is to eat dinner every night while minimizing the money you spend on food.
3. You are in Downtown of a city and all the streets are one-way streets. You can only go east (right) on the east-west (left-right) streets, and you can only go south (down) on the north-south (up-down) streets. This is called a Manhattan walk.
a) In Figure A below, how many unique ways are there to go from the intersection marked S (coordinate (0,0)) to the intersection marked E (coordinate (n,m))?
Formulate the solution to this problem as a dynamic programming problem. Please make sure that you include all the boundary conditions and clearly define your notations you use.
b) Repeat this process with Figure B; be wary of dead ends.
T.tt
oMpintiimmil
opaiz
otherwise Min
OPE fi 11 13
t.E.oPTCiI
I
1
costfordinnerfor I
days
if freefodondaye
andfor
F
in FF
I 2 iT 6 77 8
0345
Tn G
i gogroceryshopping
a day id
O
opteij
OPTCi.jh initialzirowE
for
goin
i
vis G.z
oil
O too
ofwaystogofromCiriIto Eoff OPTCii.gr toPTCisj
takes 0cm
colQ to iz
9s
I fo n tom
E
coal 0
2
wc x 3,2
b Rec
Fig
formula
if
i _z
z then OPTED D otherwise use
j
OPTCHE elseifi 3Ijaz x x 3,27 0