0% found this document useful (0 votes)
28 views

DAA Unit 3

Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
28 views

DAA Unit 3

Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 14
s *- 3 Dynambe Froqramreing %% and Genesal Method loo Dynamite Pepammfog solves problerss by Combthe the solutk®o to Sub problem. HR mafoly used for optintzation Problems. lage Problem sub pooblem 4 +--+ [Sub problem 0. : * Each Solutfon contats value , the Fellowfg ase the sebeli steps that the Sub Problem 2 clynam’e programmfig Follows, 4: Tt breaks the Complex problem tte Si plex Subpzoblem. d a: Tk Finds optinal Solutfons to these sub soblems - ! Br Tt cleves the vesut of cub problems th memosy. The storfng of the result: of sub problems #% known as memoriatin. 4: Same Subproblem @ cakulated mose than once. 5: Foally calculating all the wecaller of Subproblems, calculate the vecult of complex problem, | Ps0 pesties o optimal cub stouctuse g 3 ubioo of ophtinagaliin probleme can be obtained simply Combiig the wptinal solution of nee opttmal Sub Structuse means the sol A the cub probleme. 5 Th the cace of Aynamie Prepamming the ine Complexity woul all the sub problems but Space we StorF be Meaeased 2 WE AVE Slorfhg a Soild be detected There ave 4100 approaches dynamite programming 41 Top own Approach a Bollom Up Approach. 4: Top down Approach’ Tt follows mibinfzation technfyues & Bottom up Approaths Tt follows the Tabulalfon method. Advantages 8 4. Easy to Understand. & Easy to debug. 3: Tk Selves cub problems usher vequtred. These ave Fous type of applicatne «They ares & optiinal binary ceasch Tees a: 0/4 knapeack problem All paits shortest path problem 4 Teavelling eales person problem. 5 Relfabrlety Destn. Ogtiinal Bihavy Search Trees + It & same as Binary Seareh tree: * We use them to store and we can ceasch fos clata faster: + Buk Fe depends completely on order % whith data enters. Ex 10 a0 30 Opbfinal '@) i 'G) '(®) ‘o a 10 = re O ee 243 a Wada oe =2 = ZS eect 3 Hese, each follows binary tree rules tees abies wll be fo left site greater value uvfll be fh RAmhE side But baced on Poput ordes tree Structuse Changes: hence, only one bfhasy tree %& optiinal: Example Fos opsT & Consfies Some elements axe gven, wth Frequencies, Index ' 2/3/14 Elements lo | a0 | 30 |4o + We have to asrange the clements fb the form of tree such that the coet of the sear chfng the elements %& midimun- + ThE tree % known as Optinal Brrasy Search Tees + Dynamic proframming % used fos Solving the OBST: + Tabulation methed- Dypart programmiig? Tabulation Method? +) ‘Index te] = |S Pe Elements to | 20 |30 | qo Foeqwuency al|l2|é]3 > maw o table Ajo ta 8 4 : 1 |. 3)...8) o[o | 4 |a' a0] ae Rows=s 2? t o Ja |r0*| 16 : Colemns = 5=9 3 o\ o |e | 123 onl ° 2, Pe of ot —> Consites » mp Prepresente ro i P — The formula we use hese 1%, c(i] = mmS cisK- retest wlll eke? Here," k” becomes Root node y wif] = 2 FF PH Step-4% consfeles the cost of seachPng the Same node- co, o]=0 clutj=o cf2,2]=0 c[s,3]=0 cl4r4]=0 Step-28 Constder the cook of veachthg one mode A&tance- efon]= 4 efvay= 2 clas}= 6 claa]= 3 Gtep-3% Consider the Cost of reaching two node d&tance eos}, lets) 3 ¢(a4] c(t] = mi SelM k-i] + clk, fF] +e] y reef k:% woot node wenfl= Fe Pe SubstPtule the formula we get v clozy = min f c[0,0] +eCi2] + wloaI¥, clost}+ef2,2] soforih o 1 not frcluces —> 0. RRERL aR "7 www eesuvugeuaggge All pats shortest path Problem 2 We have to fiid the shestest path for every pale of vette Tha ditected Graph G: Examples 2 ' :] Aker] = om artes, CBE] + ool f 12 3 i ' + als, M ota a[3 4+ 0 alfsa] = mip fA [2.3] 5 ee fany s+ etal = md$2, 64g = mh fo, 14} = 2 6! [22] = Solas) , aa +e°Caly = mine 0, a+4 4 = min $ 00, #4 ear at 3 3 6 2 oo- 8 oft oe ° |e Mua] mf sales, atu] 4 a(x 3] } = mit ny 4425 = mtu ey = 6 (3,1 = mio @ 8! (301) » a'(a2]+ a'CaiT} = mind a, +464 = min 235134 =3 lg 28,3 OF 4) WN / 1 B’= 2/5 0 4 3 [Se cot 6 eP(ya]= BF orCia}, Or C43] +a*Loi] § = mo 4s ete} = mim 24) 124 = 4 peter] = oma] » 8*as] + etssi]§ = mio? 6, aray = mm Fes =S % rp» za er prorrpaprooododas — "VSS ePoesoGUeeeeecesgge Ravellfog salee Puablem Peeson Problem $ Let we have GXv,e) vy Set of vestites E, Set of edges Let one % the stavbiig vertBx and we need to vie?t the VemainPng vestites exactly once and then we have te come back to Stasting vertex of minimum Costs The % known as Travell?ng salespesson problen- Examplee 3S 12 8 4 t o 10 es 20 2/5 0° 4 lo 3/6 3 0 B le @ qo Fosmula ¢ 9(%s) = min qo + 9(f, t9h- ny Fes Isl=o HA® ale¢)_ = Y OOEDO ala)= 6 © 66 bbb a(aip)=8 Raids as ad bis ph Isl =4 9 (2,935) = mi Fer, +9(t3,854- 3) = mi § a4 (ab) h = mfp gates = 15 I (893) = mmfeg tale tes-4)} = mo $104 948) } = mib grote t = 1S F(s.t24) = mS c,49(ak24-2)5 = mo $13 4+9(9,4)} = mi $ 46h = 18 det i § Coq +4 (40$49-4)4 me 24 9(4.d) 5 mo S249} = 20 largeg) = mirScqs + 9G $2h-2) } = mi $4 g(a 8) = m2 8454 4 (4954) = mi LEqat a (Ce, ka}-3)t = mo 244 9(2,6)% = mio Ratey = Ig p)esaarappprorrPpPPprrevevengenag is\ os ro (28 3 2, 83,42) = mt Seas $4 (3) 43044- 9285.43) fees Page ais = mh 59 +9(8)%44) l : laa ey { = mh 2 I+20 7 1o+1S 2S 24 = mir 2 a = as oS Can + 9( 2 4245 -2) 9(,¢244) = mio § Cag +9 (2 S2,4}-4) = mip mee aT ae aa) = mings = mht = as = @ 4234-2) C43 + 9 (2,$2,3h-3) = we a+ a(2 234) { = onto R 9+ 9( 3,424) sc mh S Sts : tas is ( Fae = as Isl= 3 4, Cet g (212344 -2) 9 (1 $53.44) aarp tals beeate 5) 14. +9 (4) 820344-4) S49 (2,249) a0 +9 (442134 ) = me, § o+as Ist25 20423 35 7 ove bao 43 = 35 : sp 1049 (2 544) I 24-3 Relrabfltty Design + The probabflrty of workthg condPhin of the device % Called Relfabelity. + Design a systern wth bib rel’bilily and low constoatot with low cost: % called Relrabel?ty Desk. Example 3 cies 2 eae n-devites DP 4 12'S Connected ih Seside. PPPPPPPP PPP POOP EPP TO POKER ERKQgga Stage 4 Stage 2 Slage 3 BD Dy Da Dy 7] o> | b>] by F > -- - 9] Bt Ds bs Dn Maltipledevites, Connected TH paralle| % each dew%e clage- let aF be the velabelity of the devite @ vp then the Relabtl?ly of Ente system Ps Tye Example g Di — Ds — Ds — Dy q cc. cq a v, os Tq tq 8g "yg Me= o9t = orEse) 3] Be Og La = l-t1= 1-or@ = on) D. ? (-1)P=U-oaf = (o)*= 0001 1- G-71)?= 0.499 welebtlaty of stage:

You might also like