DAA UNIT 4 (Dynamic Programming)
DAA UNIT 4 (Dynamic Programming)
DAA UNIT 4 (Dynamic Programming)
h ,
A \\ - po.;y<., S., Y'le:> x-\.e ~ t \;)O ~~ , ~~ ~ ~d~ -~Cl('. , Ill l I kf'la+'.:) $ 0.k, , Rt l~o..l::if(;~
D~ s ~~'() , op b mo-..\ bfno..""':\ &o.ve_h ko .
l e~m~ ( ! ) ~~N"\u. ·.-
I r I t,· , ,
( ./, I } t' [
q
, s ,I I ~1
(. :I ~
I
I{) II
I'
\
11) q ID \I
) \
I() /0
,\ ') ' ,, "7 (, ~ ~ '1
((c; , ,~, ~ 0
(_ ( 14 , IJJ) le{
f (,.),l,o) : )
-:. ::7
C ( ~ J -' J ; rl"I /" f ((,', e, J ,/ e ( J, 6,) , t {..,, ,() + C C;, -:r I, <:: CJ, i J-\ <' ( t.; 1 ~
l,\ + -7 J l ➔• 'S , I -l :f
:: 1
C(,-),3): m,',, fc(3,c,)+eC?i,b)_; e(~ 1 .:i)-t-"(~1 !!-)J
... , 14-l):J+5
- c1
.
l C-',4) -:o mfn { ('(l.t 1 <o)•H:C.°l.),i)\
1\ -\ 1
';: \ ~
('. C.:>,s) ~ "'~ 0 { C(S' 1 :\) -11 rc~,=t)' (' l'5,9l) +cc ~1\')\
-t~ B eof:t- lx a:c/7"'-cuia /YIO. 1:r:.c for <Jra?h ~' 6vcl, M,t>-f
/10 f"' L { •j ,/-1,, e t:}e / ' '
J) ~ lo->f
.c L /' .• ,, (_ " ~) ,. / C ,t1 (
t.i <>r: t..> c. ==C, (Jo.!~LteJ of Gci[Je t.Jv tr · (/ L 'J,JJ
f.
~Loe c.cst { ,:JJ,,. oC f-Am t1tf pa(rJ c5/..or~.d- pc,.lJ. ,~ e>/elnm ,;.,,
1
.,,, .... c. .. • LC'?Jl (:-h OJ I cAe cSho ric::1
1
v<- mar b ae -A, 6uc>A t-Aa t A { ,~ J,,,1 tS O< u
L -- L
po /1, rro,n ll~rk~ t
I
4
( /<))
Lk.Y/-cJL J
.- )
I
/or t 1 ::::- I lo n c?lo
Jo.,, J' ,' ~ I fo n C'IO
.She>rlc~t- f.:Clh
f3 A{,: /J :r-t[l,I]
b ~ .J
I< -::.
C ~ Co C!,
e
(
I\ ( = 0 lf t/
.
,) 6 0 2
.~ 1 0
D l./ G
G 0 Q
r 0
:r
'
0
/~ /-;n
C)(( ~ 0/1
~W-?C ·
' ' -<m
~ ; S/ c $ 0- ( tu :; ft:
str.pJ; Ln,"'ho/1-y i co,oJ, s: ::::
0
::; (o,o)
,.
cS •lc.p - l(,'
-== s i "° c p,, t.u) I c P - P:· ) ~ ( w r w <J ~,
-PWfJ'i?J ~<! ~t / -
SC' /t'cl h.vo ~atrs
<0 J ~) Ond (/1 , Wk) h'NYI Sc
/'I
IJ < /1<, ant"!
~ - >CQ~ (Aen
~tr~t'no/('
,I
~ i (.., , 3 ) ., ( .3 , $ ) ] (3,6) j
s,
.. ~ ~
\.-
+ ( s-., 4)
~ { ( ~, <.{ ) , C. (,, t ) , (=! ,l), C & , 1 ) J
~/u~3
~ l co,o), u,~).,c,,,1,).,(~ ).,~,t.1_} c,.,~J c:,,:,J
C~'i
~/'::: l (O,o),,c__ 1,.;2-),.,C.2, .!J.., (S,.../), (6,,6)(:rJJ]
cc 6, 5) ~ ~
4 4
/-::: l/. s ..s
s':--=- 1 Cb, 5>, c =r, ~) , c~,•io, c , ' er ) , c ';, ,, J., {. J.)., , :i j
54 ~ [ {o,oJ C1,.2) (_~,3) (5,'i)C~,5) {6 ,6J (:::j,1) Ci",~))
<!-
oT t )
• L
/ P.
l.t
r,
1
,;-
, .. )
"'-'4
-
-
C.J , !> " '
u..J
? ·S
3
,J S
"F-
~
(
':l:'3 - 0
c.,, ?) ~ s ~
~ f- ,51
'X J. -:. ,· ,,.
I
~ I 3) - {. ~ I t O, b) (:;;- s' J ,$ 0
( ~) -
~
d- I ..!.o
.
l r, /1, e ,S~'/ 1/'0'l CC•
0 L; ' - ~ I{
\.
~., , !1'
~
\. e;
?,+ I i~
) ,r
J y 'A
I
?, !i .,_
ocec/1]Yc
F-=--
te /-
lo(!/ be
7/,, ,s
m,n -
"-
r-:-"Ir-ano rv,m
t, ,,..,1
,5(Ctvtenec.
~~,
~O,Sf
0-1 t.Psl-{ fJ J-1) + 7 ( Y.; J)
-C7t:Qmp~ ~ ~.
~ ;('-;. ~ a. b ~ o.. ba 6a.e>-. z; \/ :::=&J 6 o.. o. 60. Ji
•
,JtJU b ()._ 0. b 6.. 6 0. Cl.._
,Jui! ~
IC
'1c
~ L•
b 3
0.
~
Cl r
~ G
0..
b
:f-
'?5
o+• D+r
6
'
~,t\.l \ 'l.
RLUo.fult'~ 0..!:Jl~n: . '
· Ii ts G\ j)>o(Jlem {;f,c,./;- {s t.Dm?osed cL
(onnec fed er> a. r- .. be:. M~ "Te. l ·~ r
' ., t \-rr
r;/ cle ut~, Yc(to6t''t,•1y eJI enl,.'YC• WSft:.rYJ ,-$ L '"i"_,_
--._
.. vto,:r
.
:
~,
tJnL
I
I
• ~ 'I
I
'•
Orn(\ ~
~ \
$lO.Je t. contotns rr>t torc.e s
pl Oba o/ t{A_f t-Aa I 0(.1I ~· hatt'e 0.. ...mo I lvne h 'br, r.1 ( I- Y,· )mi
r.·/
r-/J,('r( /4tt' fie ol o"~rJ.~' l~
b~c&rnl' s I - { I - ,·r·) •
enl/re ~ s tern .
-£~r:-
Ocstjn ~ /-1-,rrt .s !o.(Jr .stJ'dt.rn u.Jl. H? ,3 cilc.ufc.CA 0, , o, , D3 ,o{l-1,
H,dr t.osf JoJ , e)oJ ancl /5 ./, -ve.spu/? t uty, !-Ju. toil ol enN'f"l:.
1;.stun e's /OS J . 77,.c "Ye U'a6tc,"y ~1 ~J,( '3 ('kU'ht:A O YI:'. ()• q, a-r a
O· 8
C. ~ I O..S , n = 3 ,, 0, , 0 1 , 0 .3
~o l- ( I - () ,q ) = 0' 9
Ui. = ( tos+.?o- <>o) -=- 3 I ~ (I ~
)..
o,q ) ::. 0 · q 9
~O • Lfy4,'c.J~ q5) j
.s
3
:::= l C0 •3 G., GS) C O•C.../B.,,q~) {_ 0·6(tt;,too?J
,.,cl<".3
a~~ ~"' \
B,o..t th, ,,, t- o~ rok"' i; f«~ s OY'- r ,., o. ss < ovoh (o, J
Suoh ~ o., < o..,_ < a-,.. kl- p (/) b< -th~ pvobo- btlf ~ --it, ,
6,o.v•~'"3 "" \o\,,.,I,;.\';,-, °'' ",,,d <i LO b, l"'-< p ,o b,\,,/11 ½ <-Oli
wh.ic.~ 't°hG t'.den l...; t·c. v ?C :s .$eo.vc. ~e.cl +,v 0. t ' "1- ~
-<. Q)... -r 1 , Lclx
0 ._; t ~ () O.f'\a\ Oo - t6 O.<'lol a(\~ I - + ,¢ J --He.Ye ·\:he. r't'U bl~m i ~ ' OC
Co "' \..u, le- 0."' "I' 8=1 1,,t no"c:J S, o«> ~ -I;,-.' W <I:'- ·l;\s.c ""j ";,,.o,
(c;,s;,\.. I
l(.t m:,.L(
[ °'' ' °'1., °'~• 0 l41 ~ l olo, ,Lt-, tnt) c.oh~Le j $..(\d
I
0,, ,, 0
'f I < ('J
{ l I -;:.
"( II -::
o,
0
'°1_,. -:f> '&
y'l,.'l, " 8. ,3 .!, ~ 0
•
CA'.>t{(p { "
c.~tl~ 0
, ..
w-- y " Ytt~ :
I '-"'01"- t) I 2. -:: !f-•
I
~1...!, = '!, ~'4." 3
~
l ~ l-: (. t,\- "l 1 ~ ., ~ C.ott = ~
Vo l" I v'♦ i ~
l, . :: b X _!
'?02
I 'ft" -.1
~ •4.
<l.·1~ -:.
'l. (\
iq
.... \..~ ~
"
'V'
1..
•
X
., ., 2 ::t Yt 6:-t : ~
~0\.1. ., i6
t-ou.~ 8,,. ~ -
'X
..,~tt~. .t
wC c'., ; ) :o (> C..i ) + CJ, Cj ) + Lu ( .: ,. J _t )
bJ ( t, .j ) = q, c l ) ! c C {, ~, ) -::. y ( (, j) ;. 0
uJ ( II 2 ) = Cj;(.f)
r,.,cc,o) ~ t'C..2)-l-<JCJ)+w(r>, ♦)
a+1+g-1
«>' c_ ~' ~"> : P c~) ~ ci. c.3.) + w C2., 2. ) ~
t.v ( 3, u):: P(lt) -\-qcu)+t.v(?.,3)
~ \. + l -\· l :::. ~
• l+lf.l :3
wC-', lt) :::. p (~) + '?-(1..() + W(--v,ll-1) W(l, ?.) PC.!,')+".'l,(1H-rJ)( 1,2-1)
' t ( O, .;)
g + 2,+ t ,L(
,., / 3 l (_ + c
c a ,.,o ) -t- w (_ o., 3 J
,.._ =- 0 ., ;; ) J
t 9, + 0 + ty -:: "?I 3
0 + 4t5 T l/
(. ( (, ~ '.) -t- C. C o, I.,{) + li) (_ I 1
4)
'::( + a "1- U
= :n + w c ,,4_)
ll '.:'- Lt ;;,', (. C I 3) + (._ C4 '
J l.,( ')
:: ~ 3
.,i.,+o+u
,
C { O , u ) -:: ~::I;► 1 (o,o)+ C(IJL/) -f- c..,.,(O,,q)
c ( o, 1) 1- c ( e:>, 4) + t.,0((.J,,U)
~+ !J+ JG