0% found this document useful (0 votes)
33 views21 pages

AD Assignment 2 Final Answer

Uploaded by

dibyajyoti swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
33 views21 pages

AD Assignment 2 Final Answer

Uploaded by

dibyajyoti swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 21
rae <—erer a Department of Compu Faculty of Engineering Science & Engineering Technology (ITER) i Regd. Number:2241019588_ Page N Name: Ansuman Swain Department Faculty of En; Question -| : "Algo: pent dyw-0 , hgh = Drer-tengtr— g) while (low ) ret A [lows Time ComPlerity > O (4090) Evamtle © tet ave = UP EP jlesfecled om & 1) @ mid = O+b Fe ie aaj Celie) So, Mow w= high =6 @ ma He- © Alsj< Ale) LtweJ So, ap beer hugh = 5 ana fois = Ge @ mi- peaed Aue Als) Cre J Eth 8 ang w= 4 @ able Ue < hh) (Solse ) op retuen A Low] (which os ) hos Our enfected ani. Name: Ansuman Swain Regd, Number:2241019588 Page No. 34 Depaitment of Computer Science & Engineering, Faculty of Engineering & Technology (ITER) ) Giver, Weta [28,52 ,,14,.3S, ay U8, 11,00, 17,30) () Slaxt with Jed, AGI + ALY »yeatos no Aap requerveal ai So pet [arise a ost) b1t, 28/1472 2) nov Je : é a < AnD Awap Therm e wd =0 we a Ci) 7 Lait) 2 eubiid « aot[JJi Dee) al cu4td lat 3 ious toe . Tin) TU) + 00), > 16) ~ 0”) Name: Ansuman Swain Regd, Number:2241019588 Page No, 4) of Ce ineering of Engine TER) BAL (Coxe: T (0-1) 4 OCU) ttn) = OCN) pvg (axe: O(r) So ct Aas the same “fine lavflenity As étercalive Veer Wwveruty the online nate of te INSERTION SORT algouthn with on exparme y “Online “algoet rotibn sont 64 Conkderted 2 me QLgram Bore HH Com Dordol the uPomng -clata voy ede Clert Lyy S ‘ 4 tng oe hae oo atl, any, and we reedere, elements ov iol eae 1. titel auioy 2, tere Fs Lt 9. wot YU» C47) y oved S ° Go s cert 2 Rust 6. port” 10: [2,45 4,10) Guertion -3 | vee upsive, wusion. OF the BUBBLE y) WHE the ose then ; peo bubble gore Chit only, ot 7) fh, § eel) ae * it Cront= Or on Lind 620; CoNel jt+t ) 4 (UCI) wor Cit!D) A seep ror li) , vor(i-ttF 5 Count + 4" Name: Ansuman Swain Regd. Number:2241019588 Page No SS 84y VY j he ed on @ "9 ® 6 LeU eey eve nn i aa = a e fas ? ° ” o ” ; , Department of Computer Science & Engineering R) Faculty of Engineering & Technolop t} ( @unt ~-o ) veturn ; bubtdow ree (VOC, ij) Cation for CLs Mynneny” ted Cases 1) Formulate the weCyyorence, ve {umes to the Wosut and the vate 7n)= 1 (n-\) 4 ot) . 0 » TO) = 0 qnut cae: TCM) = T(N-1) tn) one 9 TUn) = 00") pry wre TCM) = is oie Tea = (Olin oe i) BUBBLESORT G8 Xtable om not rJality youre answer with & Auilable e1amPle, spubblesot & Mable. A avdiry Agostino c& Said Lo pees ie wins Clonent vftex Aware % eho a spxlel jlen the *elebive Opder. ae ential erst, [29,5 , 23,48) eae wee BIS, 23, 239%, 40) gm seer [15 12% as 405. yh xtee [ 16) 23, 25" 40), Con Bee she clenend 93 ctth © Slar & pot seerhed and present cy dts relabve 4 Lio a9 CP int pot ch O Heloke algo seth. Name: Ansuman Swain Regd. Number:2241019588 _ Page No. 48 £ 9. — — Department of Computer Science & Engineering Faculty of Engineering & Technology (ITER) Quexion-Y* the SELECTION, D Re Copesve veion of SoRT ater : Oh : e Batic vou recive Sele ctinnSort (Cnt ld 2, cnt A, ‘< , cnt Andex ) & Of (ender ==) r retyxn } © ont K — ment nder (a,inder.n-1)5 «| ek (k] = (ndex ) | } . . L swap (alk) , aCenden)) *j 2 : recuosecectin Sort (4,1, cnden 41) 4 ‘| © glee tnt mxIndex (int aC) , txt & crt j) ll \ §(=-5) al reetn 1 cnt k= Ig 3-5) Bit (acil <@ (Ky) refurey ¢ | "y nw Ky pee bH cl ing Chimes s ence, relation, px cts muartng 1 ee wr. T= TH) t oy 5 ms = 0) 5 worst Cae TU) = Tn-1) £000) 9 eee eee. = OCA) 5 Be (1) x iy RE: many CODE U i = we) 5 s Name: Ansuman Swain Regd. Number:2241019588 Page Now _ COOCEETT IT ttt Department of Computer Science & Engineering Faculty of Engineering & Technology (ITER) SELECTION SORT & Aoble seelec tin Soxt Bnol & Stable 3 opting algorithm pecause A Avaps alco diny pivol’4 Poyvten oA not? Can yoo Ob!eWe Any fejenblence With the ofatun, of HEAP RORT Ql pUthe » Erplarn wetn, ehanrle 3 HEAeSORT rlgorem woreks Hone that dike 4clecte sy care : sont Concert a Both Ge Ontlobde. Sorting . > Fok cranple lef an POCO C4,%4,17 5/35 Selection SRT (It Psy) The montaum Clement os 1. Swap ct udth Y. Now aormy C12 ,4,4,4,5,9J Janene S27 [At fox ES a q < tuoe fhe Hoot 4) veth ba etemerd 9) gow wey 192% L457, V). Name: Ansuman Swain Regd. Number:2241019588 Page No Uf Departm Faculty smputer Science & Engin ering & Technology ( eering ER) Q bertion-5 . Dewan an effeeieng algoreth To check. éf Loxgen element on an a element heap & smaller than or ema t a geen wale a . Your alge rhordel has Oy. 4) cnitalze C=0 , 2) Rood K and x 3) fox cre (= 0 B n-) ; / check. o& ith elenect of heoP 5 Leth than ox equal x S Ya count +1 reylt = hearlr) Check. 6h Count & Quel fe K ck yes Then break te LooP Dic | Ond for G) chek OF count < kk 2 Peaint (Net onsugh coment SAKA ) elie Pront ((eyvlt) = Bet Core : OCI) wort case : O(K) Name: Ansuman Swain Regd. Number:2241019588 Page No, ga ee) a ® ) e —— — e _ eccee ESS 2D « lL ei et Da ata Pal Das Da CULO VOH O48 Engineering na & Technology (ITER) Quevtivn 6 PO. AL ay, © CMON the Tnlomenlah ony ol dnortinn Sort And Heap Sod on the Same ma for cnvd M2E NM Trrortion sarct reas cra By AlOPs oie kneaP KO pwn cn bY alaga Mok So “hich Pie M, Lenton Soret COL Rh yam ROP Sorel) ys AS PH Gwen enytrecti on, gn < Gy ndoyn n & ¥ndongn) n (629 19) = LM. 244 424 =4 nn Name: Ansuman Swain Regd. Number:2241019588 paneer Department of Computer Scien Face 2 & Tech coring y (ITER) = oO Fond Twarere ny 04 Nodoy wot “Tus chldren ¢ ne child and ro Child AA the ne OF node, th foo then. the no of Leaves | n \ & Jo Us | SO 80 as leores Rox 0 lewis 10 50 Wd hos Bo epy, AS 0 tween fo No ofdchild Lmde She nombey of Modes howry 2 chetdtien = Joo -(OF!) poo-S) a9. @ Ne mbor of nodeg in odd Mote and wnt gubtree Ledittepisrea_ 2 : A bwrawy free Y AT] 5 dejt whhue, = 6% fugit fubtree . 36 vt The faxent of fF *H node at Q height = 3 Jenner of Powter op haha % The rade nnber = JB to op = Ie er epee (rerda age 2 Seale La - fhe Note fy - Ne Parent 0+ 4 = Le] mG, Name: Ansuman Swain Regd. Number:’2241019588 Page No ‘& ood 466666656 wt bl & Engineering. o —_ (a) A bonaryy pear } 0) Powtcon. 04 the Paden Contain }oo Clements . the thir leaf node ol tea are |S} ttn ‘ps go dhe Powtion of Anta loos =| 3 \4 142 = pes +3 ae 1) Todal numb et of leaves. Total mmber of Leaves > |4) BAS ) Reight of the her tm) Res heat 04 the hea? = [dag,)0° J = 16643) vd No of neksy of at re os oof fled (Dreh No 0 poler al het 3 & 8 4) Derive Gfoumta, to Comte Me Jeisht or the KOR Larger element om @ bnrersy mor-hesf, Dany thak Comte — ay yn ot ell is shee [oJ Kees (52) TTTTTAT TUTTE TTT ~ 5 a 9 PA agth barget ont K-39 I in ™ pel ee So ae alae > 3522 > n= 099(35) S124 Nee) So ue _acth Longest Clement» ch ferent at a height of © Name: Ansuman Swain Regd. Number:2241019588_ ena ebbb6 Department of Computer Science & Engineering Faculty of Engineering & Technology (ITER) Question: |p», Convert the Soven artim Az ies < 24, 4/9,16) 9, 10,5, 4,12, 45407 rb 2 VY) May “hea D) e ~heop @ BAS MAYS sa No oF = Canfou son Noo} Max~heoP ip = fe No: Of Comforuson: | eno min-haoP com: 11. Name: Ansuman Swain Regd. Number:2241019588 _ Page No. Department of Computer Scien & Engineering Faculty of Engine & Technology (ITER) Ke An BUM Pe 22) 24,8.) 4K" yy, § ST > ('n MMB do, fal. pwatet of cold Lt ; Name: Ansuman Swain Regd. Number:2241019588_ Page No._S | Department of Computer Science & Engineering [ Faculty of Engineering & Technology (ITER) Quertioniyg The follow Way LV brvlaty the exttnu Poutre, (ntegera fiom 1 Do [> tela Tale lela [telly [aliala Vhat Will be te é ve > ) de ae hae awe oF A,b and 0 Yat tia any Ma -hesP--@ < ae _ © oo Matta ts Or. So the awe of A =IQ. Os ct shold ba all ihe 13 ana greater than 10. Vale of + 1 @& ct Apwld be Greater thay 6 and Anoller thon 4. nae of C= S, ay cf shovld be greater thar 5 and fmaller than 2 : Vale a) d= |} 7 & oF pwuld bC Breaten tren 9 ' a gral fran Werlidy -13:- Yous gua gen & {Min Fore aS ie eae Pp wetn 0 Clement Bena O kop K Youn task 4 tb furs all keys coy eh trot me AK “than or uel OKA Mitel Orne ¢ i) Piretoxe, an Pfecient alymetion Lb Asbve tog Probl, | > uy Supriya. tight bond Pn He manning tome ot yorur a aly tet. i @) Read bey k . ‘ Q Ot POS >= heaPsize, Sp then, rveturun sr of eap(ry ) x. ‘> Chery Mecbirty s Name: Ansuman Swain Regd. Number:2241019588 py : ; Be No. Department of Computer Science & Engineering Faculty of Engineering & Technology (ITER) @ Sruint har (Posy ©) (Dak Rane fuoclon (c, lest (Pox)) ® CBU ame sin clon Cx, rug (03) © intttolite The ledt tingle rebtr (240+ }) (nrtealie the cusht dunctcon cot (84 O12 @ Jere omelet o(a) wey 4: Dedine. @ mox-hease 2464600066 and ctf Conk gues » ~~ Kon. ¢ 2 . see T) an m9 | eonvou the 20mg A= K20f), 25,9, 23,1LF Cnll Oe rte én te te 11) CorPlan, por yor inoue o Key 22 e en paary Mee that ey OA mo hear iA a secieee ms i : wtoliy ji te mox-heap fr = at dcop Preecty, plates that for ay gem node ~ ae pene the ae 7 that rece, 4 greater > tye value of CIA children b 6 66 vbbbede o j @ ®8 @ inert 22 Ct ton CP ©, a 3 7 <22 <2 ao ; es Name: Ansuman Swain Regd. Number:2241019588 Page No. S 3 mycrted én the Veale of 7 as De ba pare tment Quegy of Computer Scie! ring ~~ *euly Yo Engineering & Technology (ITER) SNS Dow fear port Sollps Hobe aoreting- Fito ex bY \uxtafy> vith an eLomble Kop zopef C&nal O biable AVUNG algerie Becante dixciyy wom the hear spit (t cloant Vorentee that the Preservation, of relateve elements Aton . a an wouy Dp 8, 41) Sn wes COU Ud and Yy ane Jtuo eCopat horny Bul be sath wt (2 a4, ci J aoe ey see the selative Clement Y Ye fa nite » Bye tm there elokive — Prtoiting 499 ee FT ATITA © ~Hente Reap xart cn’ @ ptoble sorting © Question 16! wieete a puedo to check 444 a mortap| © oH nod, Then check, eth valteh < 23,14 Jy 613, 0107/05] © & max-Aeop? of pot fren bovild Q max heal. -fum tre c Joon qo. ‘ Preicecoote ” ‘pr —— «Real and all cloments im the ado & Crleate,a Wwolean, functor & Heap (ext only, ot ¢, ot ty} (i 2= 1/2) = Oo [241 bh at [iJ >= an [2* 49) &e 6 Heap (au, 27¢F1,0) oy ty fkaP (avr Qtc49,n Netxn twe - ‘i % )) felnn forke 44 oo ata a ee t Name: Ansuman Swain Regd. Number:2241019588 _ Page No.; , ep. force es ent of Computer Sei Sulty of Engineering & BD Caen MAB elo nl 4 C23, 1) 4, 613, Jo, /,< Futieng thete elomentS tn this Phuevdocody Me hax retorred fake We Con See H by | Ley Upding Q thee, * d ® f ng /Y) rL Ot Anta MOK fee © x 2 3) as 647 o ta 2 SP the max- heap i Aa Quation!F:. Tluxtreate the ofecation. of MOx-HEAIFY .@3) on the Annoy A ~ < 24,14, 3,)6)3)01,57,)24@p TeLypdriate the see ieas % OF Go wc on fe Dovw, 4 Name: Ansuman Swain . Regd. Number:2241019588 Page No: SS__ ¢ — © ® — <) = 4 12 ALgont, —— what & the tpn tare JAP Dp y ay m tp fort an BUOY, of Length "Ceding, ih, FIL Nd i 1 order treat A rhordy, suclod bp tt oder. ) whak oll be so! s On te 0 Peonmeny Ly 4 aAd0t me_ Ff adler oat ClementA we ablipod. "pi TEL C TTtT 4 St Contong Ot arrey 6 alec 20;ded On Hiden the te fe Site nen. the Teme comPlpatty of ak gorithm & Tn) =O (nlogn) andra, e HEAPSORT e ~ ~ . 7 DF The ouroy & tn dereondina, oselor Shen due J\ Mwnbox of orb tt ale talg O(nlogn) times, , Question~la> GuePoxe, wsttadl of the ben heap we CmPlement the Pruopety queve Ofertation’ Uvry a k-awey (K 72) : De Sea inthe te. ison hag shen On i) an Y SPeuftally, Wwhewes ase the chbedrert. ae. ae Weems Porition. ¢ oF ther tocoted ”, 7 Tnhlemep tation’. Aum O \ased. Onde ruimy oF ang yON Onna fuerrererts a Kay heap Meh. thol- we 1 wy Parone of te mi i ab $ a echiddren oF te rele at Cnden ¢ Ve at. (K* D+l , Kt =~ KEK oo saueee ue. Name: Ansuman Swain Regd. Number:2241019588 | Page No.:__ EETTTTITITTLTA SN A a ee —__— ngineering logy (ITER) ®) Analyze, the fusety. We ofealion 4 [7 pYSFR7, x4 RACTMIN ) totdmnented. tn a kary Kear v4ery kre Mondor al90. Vhat ane tie pumberal Crt podlorrmeal Cn the wort Caw fy had otyeten 9 ) For Trent Fer |K number of nodes there edflebe Fach Level. of the hoof pequeces K-) Comfatu'son SO he number of Comouixors 5 1(k-)), £97 Tine Combe xe'ty > T(0) =O ( &e3, n) D { 09,9) Va ron Fo EXTRACTMIN ' Sémalor 20 Menor there wilt be K-/ Conlecen an lang avats £0 the NUmbet of GomPouy tary Ch :(K~/), Lady Time Ulett, > 0 (43.9) Dosw abouk the. oPlimal valve Of Kk L get Tho pat Perfoumance, ©” the pweber of Corfarctons uxed tn there aHQhion a : 4 Pe Pofolas method elbow method which cs Upeel fo determine the pPtemal Value of |< -& fexfoxm Fhe vest, are pawe pets the. vouos values oF : py the. vabee OF of K cncreapes ,-pnerte Well be fewer ca a én the. Lx. = Then the Oftimol. valve for would be 4. TEEbbeeesoce lenerrreae es) d lehind thy method Of that tt a wat uth Changeng k. Name: Ansuman Swain Regd. Number:2241019588 Page Nox_S 7 De, ePartr F MEN of Co: ule mputer Science & Engineering Dou 2 of Engineering & Technology (ITER) SUPPE ei Oe we, only critwested en mint mi vir the Winb o ‘ py ‘ » Of mover (Pex foemegl, Ofes ‘Sas (lion 5 cn the Praonity Wee a ) ‘ Wold 90U Chagy, Li a Mureaxny manner Uhat Valve, x Ne geen Re The, Larger tho K veld the swabey a] ears wilt be ned ceal ct wilt le efte'lent (CExtertions ) Some rake cays A0ts®, tie letter vate of K vill Jone wed Cire CH the Ruvsuty queve her machinary yr~e~ dofincol ) and MIN-HEAPIFY opescation ond desuiva the Light VPP nds on the punningy time « wee pracedvcie OLILD MINHEAP Creaty a min-heap from the gcven asioy while MIN-HEAPIFY ne cutestvely mamtarng the min- heap fyetetly Guilding @. Binoy Moh = err) 7(n)= 2(%) +O) pull a Min. -heaPity = © én) = O(r) — Ten) =f) 4 ow » TMs OC 44,0) Name: Ansuman Swain Regd. Number:2241019588._ Page No.:__ ) Fomlate the recurrence prelatrons for BUILD II)N Atw on TT eat Me sppppp pps

You might also like