You are on page 1of 14
DAA Fes No — 22MC3004F Algorithm toe Graph Glowing using Greedy Algorithm . Step Peet GraphColaring CG) be a, dinchien: Oba p et LE he bey number of vertices of Gas fyv ivy, Yad Shep 1A coetelims 0 250 etter Zarate of colours as vertices | available as {61,3 .,nh Step 4 1 iy veaar FO Ones ek Ge Ti Maat att Sy) available §r coleuring verter v; 15 Sek: vit 17 2Gnstoler (1° 2 (vari eent ceeea 5 toler VJ = key Lb om be the chrematic number mz0 5 ma ro calour lV] Pm clown) Nj etjacenE with vis Skep 5 Step « Step # 1— For each uncoleured Vertiees GG - {ks Step % Ce) qereey Step 1:- Ff Cien), Go to Step 6 Step 19 i= Return om p wheres 9 is number of vertices Cie NRE oy vy Selution \- v(q) e L%y Mas VEY, Yoo Yea Mes Mo } Colours {12,5,45564,8, 4,105 Now, C7 Lh ssbb b5b5 bbb bE Ge tury e = {43} Ly se} c. {085454 Ge duyna, 564 Cee $1,234,556 14% Se (135456483 ‘ 1533,45588)15 = 1123,45648,3, 105 Set ist First colour in C21 colour (vy = For Adty Cv) = £Ve5¥syVao% o¥y f Coe Leh 10h = 2h Gye fry sh 41h = (3h Cee FuaZeh- fy = ioeed ef, LLG56h-15 = {4456 Ce = 41,2)3)555% - 15 2425555 De! 5 45 Now, te trl = 2 civte Golan ces Clate ede m2 2 For Adj (y= LV, % 5 C= Luyyetysh deb = Lystes Now, ital 23, 2 10 First colour ty Cy 2 2 colour L¥s] = 2 moo For Adj WS) = LVM %%$ Che {a4} -12y = [343 Ge 12,3456} - [ag - fnescy Ge {ae esos te Pee. a3 Now , Firs colour in Ca =3 colour [%y]J = 3 me3 teltl= 4 410 For Adj (¥q) = E¥.¥55¥5)¥e,%po¥e § Co = 113,455 - 133 = Lu4sh Ce + 14656§ - 135 = 1552s Cee £34565 - 133 = 14,5675 Cee 148556525 185 - LL eA 5548S Now, tzitles 200 First wlour in Co =) rs colour [ls J= 1 m3 For Adj Cis) = £%2¥4,%er¥0, MoS Cee [5685 B= Lisson As = Usa} i Cot Lu b45 550 vey -UT- Lab S ee yes Now, ivitl +6 #1 First colour in GQ =4 i tlour (465-4 a me & i= for Ady (Ne) « L992 48945 = G? hase? § [4h 15685 i. Gy? Lyaehs65e1S “Ath = Lyn35eneis Now , (et! 2Fzlo Firse wlour in Gr 5 colour [Ve] - © me £ 5 @ 2. Tsb Seouenctng with Denallines > Consider the profits of 6 jobs as Chi > Pao Pas Parte ste) Clo,25 13,12, 35 with clendl (ines Ca 24s sds day deve) GIES op), Cate Tehs as TLD for where, 7 belongs te maximum deadline o& jobs Given that number ok jobs Cro & eu Lcdis Capeslisn decreasing order of pre fits as Biase fate sial optimal. sesuance Fog] 3 3551 -¢ BUS | 0) thle {s 4 10 s A 6 Now, [0] =TLoJ=0 mpjes ka} foc aca a (1 stankion™/ (kee S represets Tob fe */ w]e ands Alf lreth) eS tet —> False AplreiJ]=3 > 4bI-5 Ged Pk boop */ aperd)-s 4 a0yer ot APPA? # 1 > Tone s[aJ-2 kekrl e2 /* TE bop */ For 3) we ge [* Dh Tesetisn */ cial oS UIs ea ee ee vetlel Ljtred]o3 2ACT+ 2 anh Aft ]=8 te® > Te yet-l 20 A[j Creo] = 0 Sd[sJe2 and ALjcreoJ]-0 $720 —> Fable /* While loop */ A[jtrs]]=0 < dfs]-2 and AfsJ-2>v20 > True wis) =4 kektl| 23 For i= 4, We geé vines J AfjtresJ) = 2 > abeJ=3 afjcr-3J) 22 < Af4]-3 TIA] is net needeal te Le inserteel in T Foy ies we get ake 3 ai cresJJ o> > Abe! wete-le 2 ALj Crea] - > AlsJ=! were) > as]=t T2710 aly ore ole o > alsJel AGereedJ=0 = Aled! s[sJ = ' bektlo4 For in 6, we get vekeh A{jtret]J +3 > Ale]=2 and AG oregyJ=8 te aljer-3J)> pp afejer and Afj tre sdJ°2 fres > False yerele3 [* Bia loop */ ee Thevation */ and Aj Cs-))-2 ¢ 3075] —> Fae Z* While Leap */ WGl=3 S423 — 5 Fale J Tf lp */ 748 Te rokion */ afjtr=sJ]= 2A res —S> Tree Ajeet Oe Agrees free —> True /*® While loop */ ALjlreoJ)-0 #420 —> Felco als]=1 > 420 —> Truc /¥ TE loop */ (4 B® Tarnbion [taste Tteretion *&/ — me 3. Pets frllewing matrices using Sérassen's Hadrin Holtipli- en Ae'|> 2a ane o 2) é 34 $X3 Com wting Han (3,34) = 4 which is power of 2. rey bad Now 1, Eesiviting A andl & by inserting mews fF columns with clemet 0 te convert it to the berm of Kt. is Ae anol Be 2 ° 6 ° 7000 1 1 ° 3 = pegs o a L A ° o ° Now, Spl:bbing both matrices into (BE submatrices . Merefores ca An = a | o2 Ae 14 Al Le A i, Compating the # matrices cach of ALG a 2 (Ant ae i J B,= C8, +8.) = Iie jal 62 ‘DiNzy = (An Aa)= i B.= (Bai + bas.) = [: | Age (An- Aa B52 (But Sin) = i 4] Bq = (B22) a ee Ag = Onrn ayn al Be = Bu S : j: 2 CAut Aw 2 ) ie ny aise A; =A) eae ‘ ‘4 | F oa G2 Gur See " os] 2 eae 62 (t.t- 6 = “4"=! (‘3 se Cebu = [821] Now, Computing 4 matrices such hab MH; =A: Bi as, 2 Ab, “a 74 He = AsGe = [ 10 eal + oe poAveem 6 5; o ¢€ Hye AsGe = [16 4 of Beige ete en Nats “Ff J A submatrices Wheeh Now, Computing Halan AG Oty Py = Me Mam Hy tH, = | 22 al fine Hetty 3 [12 5 Sad 8) i P= Hee Nee eG fee Mh-ty My +e =[28 15 Oe oo No, Final: Solition matrine AB is given by, Meee ele Blk oc leat 1S ge $2 28 15 Abe [fu Pin fay 2rd But 147797177 4 Algorithm for Multiplication of two binary Numbers using karatsuba Alger then Step 11— Consider tivo integers 0 anal b Step 2:— Compute man Clergth a anol length 6) ancl Compare with Powersef 2. Sek n as nearest power of 2 which is greater Han or gual to man. Step 3i— Add 0” ak the “4b si not egual t n. Step 41— Create function baratsuba with in integers Step 5i— Divide beh Ke in de of Integer 4 those length is puts ar the mecli fieel agers ine tue egual parts auch as Dred Taal a2 4, anda, anoe Step 6: TE h=I the return at b Step # i= ante Nera [% length is reduced after x nfo. every Teration */ Step Bim Now, Aa call kartruba (4), 6)) Ba call kavatsuba Carb, ) Ca! Ue parse ee De C-B-4 rebar [Pou Cle, 2#2) * Al + [Fw Cron) “pre | Shep Vim End Haltiply tuo binary numbers + Az il00lot and Computing Length of ma) = 7 Nerctire Non, Adcling 0’ at lett side of ALE Lo Therefore > As o10010} and Be 20l(000) [* Fit Theration */ a2 B = Nooo), » taking nz3 rake iG length epual ton, one 22> ojo} b= cones ba = oar New, Ne) Seb nz nfo=4 De CcA-B, Iteration 2 br Ant cu alo batt Now, 1+} Sek nz fz > 2 A, = Karatsuba (01,00) G, > kavaksuba C10, 1) Cy = Coltte)(oor 1) SPreteal ee D2 = Ca-A,-8 Newt, /* Tterakion $ for C *Y Now, A,o karatsubaCoto , 0011) Bic bavatsuba Co10!, 0001) C2 Karatsuba Consett, 0011 +001) 2 Farabsube Cio, e100) —© a ays 10 a,e ul b, 7 ol b,= 00 Now, 9+) S& ne nfae 2D Non, Ay 2 Paeabute C152) Ba © barabsubs Ciee) Cy 2 bazaksaba (108 1) Da 2 Cy Ag Be /* Herskion 3 for 8, */ 4,201 a, =0l b)= 00 bp =01 Now, n# 1 Sek n= nfo 22 New, As = baratsuba CO1,00) B, > bavatsuba Cots el) Gs = baratsuba C80, 01) —6 Dre Cz-Ae- So [* Pteretion 5 for Aa */ azo asst 67° be=o Now 5 nt Sek n= n=) Noms As = Karatsuba (0,8) = 0 Be = karksnba CV = 0 Cs 2 parckseba CHO = Os = ee —® AGs0 T¥ checabion br 8. 4/ /* Tterkion Jor C2 */ ae] a, so a2 1 ber he bie Now, a | Now, 04 Sek ne rfa 2] Seb ne n/a >! Now, Ae 2 baptmebaCiineem Ho Ane berntoabe. Cy ed te wha CL 0=1 Ge « barabinbaca) ae Pome RENO ai0.5= ua Ge = bkavetsubaCi,10) 210 ake picks 284 a 10 de> Ce-Be-Ae #91 ya oe —@ Age 110 i /* Theretion fer Aa #/ /* Tterekion fr Bs */ a,20 as a2 0 breo bso bie 0 Now, n#4 Now, n4{ Sek nora =| Seb ne ofa =| Now, Age karatsuba C00) = © Now, Ay 2 karatsube C0, 09 = 0 Byer baratsubal iyo) = 0 Bq 2 karatsuba C 1,10 =) Ope Paratsuba lipo) = 0 glamena sg Pre G-Ay-Be =o gy Bigeie na A®= 0 AB= [* Teration &r G*/ /* Teration bre At */ ar20 4,24 a2 0 beso Lene jl Now, n#1 See nz n[a 2} Be oc n Nowy Ap karatsuba-C 1,0) = 0 Non, Ay; « Karaksuba C150) = 0 Gp: beratraba Core 6 By + Karaksuba Co,1)= 6 Cor kavatsubaCt;1)= | Cy « Kevatsuba Cy) Pror Cohen +1 @ Dy = Cy Ay - 8), #1 ABs to a AB z 10 — bp * + YP Dterakts, br eye a.) ae) aye by 2d Now, ne} Set ne ne \ Now, Ay + Karatsuba Ci 0) = 0 Biot baratsuba Ctod20 Cis bayetrecbalOts30) 210) Dir > GC, -Aa Bi = 0 Now, AG = lo, AB= 0 —@ Now , Computing for C 2 10 =o i Ca Age By ol AG= lottoo 1. C= tolleo Now, Computing for 8) ° Now, ABs lol G2 10l Now, Compubing for final Solution : Ay - \oole 6,2 101 C2 pottee 0, = o1orol 1 * Lteration fr Gq ws acl a= ot b 20 Rael Now, »#1 Sr none >t Now, Ars 2 bartanba(b2)=° Gry > baratsuba(e1i> Cie * karatebaCiti2! Ds ¢ Css ~ Ss = ol Now AB > Hl Newt, Competing for Ay (aise to Gr 2 to Ge foe) D2 G-Ar-Br 2 oll Now, AG o 10010 +f, 2 19010 We Now, AB 2 1001101010101 | Revere, the product =£ given tws binary numbers A> i1oorel and Geilooo| is AB= tooslo1o1010| * = 27 3999997 7777707727

You might also like