Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views19 pages

Ada Assignment 1

The document discusses asymptotic notation, specifically Big-O notation, and its application in computer science to describe the performance and complexity of algorithms. It provides examples of various sorting algorithms, their time complexities, and the implications of different cases (best, average, worst) for their performance. Additionally, it touches on the significance of pivot selection in Quick Sort and the efficiency of different sorting methods.

Uploaded by

dhaivatsheth2004
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)
9 views19 pages

Ada Assignment 1

The document discusses asymptotic notation, specifically Big-O notation, and its application in computer science to describe the performance and complexity of algorithms. It provides examples of various sorting algorithms, their time complexities, and the implications of different cases (best, average, worst) for their performance. Additionally, it touches on the significance of pivot selection in Quick Sort and the efficiency of different sorting methods.

Uploaded by

dhaivatsheth2004
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/ 19
Assionmens =. 4. what 1S asymrion notation 2 Find out big -oh Notation OF the Fena= 3n*4+5n-7710. -__ Asympdiotic Notation 15 Used 1M computed Science to_desoube the Peifostmance _G+t_Cornpievlay OF an __algonivhen -__ bis oh _horasion of the Fond: 3n745n+4o. In this case 1+he_ +eim Can) gsiows Fasiei than C5n) Gand the consiant+ Cio) Therefor the bi9-Oh. notarion. fox Fen) = 3n?+5n+i0 is i — ant 2 few nl 380 10 This 16 constand Gnd does nor sow as nr Incsease =) AS n->S the n® Joim dernoniess and Ihe 7 consdants aye not Conside, whh BIg-cnotatun Thus Fen) s3n@4snrio $8 BCR ocn’) SS ee slate ent WIE Cortiecs 2. siaie wherhea the — ow Incosiiect Oo —— ae ocfen) 4 O' aeons 2 @ CZF I) h 2.1F 3ni5 29 dhen 4. acFOn)) t OCFCNDI=OC c2Fend? This _siaternent 75 cosstect IN bigo Peres on hen oo enc on one added jogeihet the deigiminend 101m 35 _parseived Adding two Funcions whth The same Oxdei OF Quoutth Cdenoied a5 @ CCM) Hesvits in a fonction _Thatls Stil) OCFCH Therefost 0 CFEn)) OCFCn)) can be Simpuiétec ms _oCzFen}), 2. TF 3ntS= G(r) Fhen an1S= OCn®) “his _Giaiement 35 incosiniect 7m big o notavo the |owencase “oO” poration _*epsesenis & siiicy upper bound jf 3ni5 JS denored as ocr?) 4 i+ means that it has an_upre bound of n* 0} 1es5 However ipdoes not jmpiy ‘thar 3n+5 15 Sinicary ess than Cpt, which 1S What the Jowercase "0" NONAHIONS Heptesenis sa 3n45 may 9 mas nor be ess than n2. Zot Whe Foowiny NS4 OSING Q@vICK SCs aigoHithm £51916) M1461) Also waite worst and Best __case Gnd _avesiage case OF Quick S021 Algostithm . Pywiange 4be evernend jn an ossay . or 2 3 4 5 © 4 - EID 21a : pivod 1 aT IF ACID A CPIVOID | dernernent J cressa [a TaT2 TTS] ¢] 73] | NEw uu os \eF4 Subssiiure ight Subse. __ Sier2 Now mageiaa tain Gvick Sor echo aes FOES? Pivot ® ~~ Hechange ACTS A CPivo+7 “=o if Hene 6 elemem alsicad ¥ Sostted STry Plemen 14uve Pivot Xs J yiechanse fA C37 &, pives su sortted pe [a oe BE] | feted = Piety 3 | a [ws te set ae sechange ALITE aS [ ACerivot) S [ aa | 8 | Se ae peels Crea: a EEE _ 13 Finany end first wit be a oie=e TEE i Time _comPpiex}}y OF Guitk Somat fe WworlS} Case Time compiex\3¥ otn) - Best case time _comerexfiy ocn logn) # Avenage CASE TIM Comprex Hy SCN toa nd — _ 4+ Demonsisiare _ Binay seach pnethod' to Seaich Key = l4 1 ftom the aisay PEsZiOner ae Sulatlone en iCmieion =) Assay ! Ae [2 [a Js Te Tio (a3Toa 6 > Blnasy Seaich If _the key 19 1 the _Seasich ‘Haie D__Snviar wiay ! A = tzu 1 Worans _coniinues in the (ert air 5 __IF the Qseatest tt Continues Into +b Flo1 (314,609 2 low = 0 Cindex o€ 4 eremens) + nigh =F Cindex oF tast- erements on sosied aay by stepeaiadty dividing the search Inisived jn Har less dhan the middie eteenent » caicuiaie middie clement mid = row a high | : oa ~_ + middie erernen} AC3) = & since [Ke 4} 14 & The key mest Be In +he sight Hair 4 5S © FF A = £10,131 14) 609 + carcuiate middie _indey. 2 o.omid = flow +HIgh [ J middie Clement A663 = 13: since K=14yI3 dhe keY Mest pein Hint | Hare . : 3 + opdaie low © Highs F SD Ast eod Caicviaye middie Index mid = [164 Mah | CS ——e = TAP -_tmiddie_evement A Gey 21a) since I< =14 = 14) qhe Key iS Foond at Quick Sostt Fora dara ag 5. Tsace the As € 6151310 HF) _ : = = 4 eS -) Aysange ‘the _eremend 10 SN oiay 0 ° ee c nlplol alt ]9a 7 7 + aie Pivot 1 J TE AOD mecnanse AGAIG ACT) eR ro a Ta eles] then Pivoe SAI : _ mMecNang € A C312, pivot a — -_ \* “sechange ACI) BMH Soden phe Gusiay 2141 6171 S14 bola, ee oral cae lane oo go how Cwithoutr Ch ctugn show the avick Sete Peifournance wih soch SnPor- = soming . evi be arfacied J Guieksosy PesiFosimance Havily derends | Gn jhe choice of Ihe Pivot e1emen4 Th jhe worst case scenario TF the } consisianiy chosen OF pivot 15 Y Sranes} GN Imigest element In the isay Quick Sot eFFiciency can degrade. ansay (24161 Ne 1S 112, -)\ tn jhe alven GLI TK SOMt ABO ais 7 miyaee ) SF he consisjanily Choose the fias¢ Ger fast “element aS the iver the pesiti soning siep _whil divide jhe ia%y into wo with highiy impedence sizes Sub - onHnay Case whase pivot is ler!s —_ consides_ the chasen aS fisis+ Ciemens C2)? Ll) Fist paiioning ster {The eisay 1s, Painoned Into deo Sob ~ViHaY, + [2] Ceemenis lessdhan 7 equal clothe pivet 5 DY sekond (epiidoing sre Ctemens Dteato-! Than pivot: __second Panioning Sicp! The second Svb- ay is fusthen divided _ “foie. mi “aie ie IU IBF) 19,26 —_flement — gsiatast than Pi Pivot _CemPiy Sub anya) At_watach SIcP_ two Pivat erement Sapsates the away into sne smatl sub -arsiay and Gne ietee Sub-awiay This _imbiended Parnoning Hesois ina srway eccvsission _tetee tt whete € Smanesi Sub-aisays Has amy one __etemen# G@hite the taiger sob-aniay coniains the’ sitmainina evemenis + “Tyace the mesg Gon Fox daa pe € 615, Bityloy oy diay -_- 2? 4 4 < 4 2) Ele 3 i || 14 q _& pninde _ whee: nN:G=) a Umclamenate a eon : 2 — aeiesanentcoa —_ [eTsTs py i v sy _ Soot the Follewios Nvmbe: USing Heap Sostt 24) 10,50, 40,30 . => SiePS fos Heap Sost+ ) Bold A max near’: convela The @siay Imo a Prax hear. 2) _Eocinacs Clements! Gasap the Moot Crmaximurn etement) wiih the last element then steduce cYhe_ Hear, size Gnd Hearing the soot Yh to mainiain the hear psopeuy | Build heap max! + 46 Becomes Now soot Of . IF Subwee. Ihe mar heap and_- oot . 50 Becomes he _ js Fosened and Re belid “Hear he 1ast eters | 5° r en —— PS 6 REE Remove a je GP Mege She Creme Y ea — _* swap the sicot 4o wh last element Or Rernove 401 Hear size become 2 g SwaP ecremens Jo wih 30 Rernove So . Heqp size become 2 g Cosstent hear: | ent Swap sicoy with 20 wh last Clee @) “Remove. Pf Ana Simiied aywiay - 6 ' 2 3) 4 to[ 20[ 3c| Gol 5° 4. Soot the Rest case sunning time _OF ait thes aigoslihms in a non - decsteasind Soest LES 1Guick Soot ; mesige Seat 1 Counting Soat | Heap SoM? t Seveerion Gost 7 Bocker Sot , Stiensen _AlgexHhm _osiden of the _ Here }S the Non - decsteasing S Fox the given ss 2) covnsind sot ocCnaKd _ counting ses has a _stonning time _whete on Best case _ ‘ur © iS the number oF _ _ eremenrS Jo be seated and KIS the siange OF \apvd vatves 3) LCS Clongest common subsesovsice Ji 0 Cm* nd The best case stunning Hme of theles agesihm 15 Quadsiatic whee mand n ae dhe lensinS SF the input Subsiesounces, 4) Insertion Sosy 2 OCn)d Insenstion Sort Hasiineet Best case stoning fime when the Tnrvy is axeady Sorted 62 neatiy Sostied. 5) _mesge sovd ! OCn loan) mesge soit has a Best case xHvnning +Hme oe nN 109 NM which occvnS when the Input ]S ainteady souied SH Nearly sastied. 6) Heap Sosy ? 6Cn tsgn) Hear sod tas a B54 CASE sunning +Hme OF Miegn whith GccuNs when the input js aimeady Sorted ort neany sosiaed. 7.) Guick sont {olen 1es.n)) ‘ 7 Gvick Sosit Rad Begt Case svpnind dime . ofniogn which accom when the input \ 1S Gineady Sestied newly sootied . ol & Selection Sort! Go cn®) | Serccnion Sort Has G& Qvadsaric Best - case “sum nning time wheie nis the Mumbey OF elemenis fo be sosited. 9. samessen'S — Algomithm ! OC M1092¢9) sinessen's Atgorlinm Fost Best marotix “mouiPlicasiGn Has Best Case AvNning time oF N ‘tained fo Powet DOF 109 2C4) “18: APPIY mmenge Sort Gigesiihm an wisay A= £2) whay 1S dime compreaity puide where i nee =) E ane — [tyafal =f : \ /—\ ay BT 5 | [Tat (Te) | dd I i | Dla [atel ral 7 ray maa 5 tla 1 yi 7 Je [2] s}¥) | (Lol # <= [4 DT 2T3) 4] 5] #]*[ 7 the me commexty OF merge sont Inworsd. ease in OCn 1990)

You might also like