0% found this document useful (0 votes)
22 views57 pages

Data Structure Notes

The document discusses various types of algorithms and their complexities, including sorting algorithms like bubble sort, quick sort, and merge sort. It emphasizes the importance of analyzing algorithm performance in terms of time and space complexity, providing examples of different algorithm types and their applications. Additionally, it introduces data structures such as trees and their basic terminology.
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)
22 views57 pages

Data Structure Notes

The document discusses various types of algorithms and their complexities, including sorting algorithms like bubble sort, quick sort, and merge sort. It emphasizes the importance of analyzing algorithm performance in terms of time and space complexity, providing examples of different algorithm types and their applications. Additionally, it introduces data structures such as trees and their basic terminology.
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/ 57
Ifpmation Moors Data shoal wst Dako maf be og Tubroduetion Dolo’ Se uw Fee catleshion of “Logical and J proceed dokn vc zed aos a. ponkeulon modrouraheod Y ied tor ohov woe, THe Aagieal ond suotremotical model of oxqanixoho of dato u called doko ctruswe Ae daira A porkinsare date wodsl dopands on yay wat be wich onough a shushwu bo wore Be athucl xladiouships of yhe doko ww the soak world ty que chewlwee chould oe sivple ome Soot oun can atedively prous Jue doko! whan weremory Aqpes of colo. shwdlwoet + ‘pes of_dele Se 1 Lineaxt dob. shred wee Be Ainekk Sieked Just Wp cheat jy Soak up Sineon ae Urear Jobo. chr, iy dreador Jiwked Usk ip eae ay grap 2. No Aoshrast Dabo. type CAT) Apt % a eadlattion of oka Ye ond & sok of opeahows Mose ae podprued ‘on those dole tem. ‘ Te uo voofud Joel fer spenitging Bue Negical propadies a dota Jape Example Stork, Queme. gad «Get 1 S w 5 > Rpose Oo ‘a containing © Works. cia =). Aware clemonds ©3,\0 et hoo beam Mec in Sue cvowy 2 Hee vronpived Ye dalek one glemtend wad HY TU being deleted, ron Ahe cowry o will cakoo stosk. Instead of 7, y 3 bing Added dean Ae sewe arneg soll oak on quest. 1 / Algsithon : Av adgeton uo fivtle cegurnee of vmcunbigurus a for cobsing a problous, ie fe slteining o required culy for cay Jegibiacke Sapa mwa finite aunount of Sime Tr con be ‘tepresanted) iw vastiows fort Problem ¥ Algortou Laput ——oflompaFox] — Cudpsd (ox its) vt Calgesithanie celubiew) Algorithma: Performanes and ollun ovpeehs: ““Awolysis. of algorithar ix the deavitical dy of computer preqram porforvionse and vesourte wage ” Howton, designing a gread cofhane u uet juot obeut porfpruonee, bud a Lick of othr Hrings Be « swodulasal waintoimabill user al endliness etre chwss see] robustness exkenoilidy seoodanity programmaen’s Swe. “Bo_Vypes of olgontnms Porolled Algertiou “Didvibuted Aigortaus Mae ave hoo \ipes of oan Huvickie - Yo analize an al qonthu 3 ga works, but occostionaly oils Detouenistie— Stops ot kun aud well defined - oases of algorithms: *Reude Perea: Find all dhe posse solaions aed ale fhe re wy (Fiviel Sting Molehing) 2 aa ge the of + Bide ond Conquor! C Quick sort) + Deerease aud Conquer: Binary Seares) * Pramoforn oud Congas: ee EUint notion) * Morale Snugpovennt (Seladion Sort . 'G Metled : =n Ihe weanest voile oud find Hee sol ey Sohesman Probl) It was wok be dhe of + Dynausic P. ring (Motsix "Chin Hit) + Bask tracking » (8 Bueeno Problen) + Branth ond Bound + (wapsou) + Rowdouieed + (Randomized & cent) € +A scudion b sold Is be etticent (or vdolively officent) cf it solves Hoe prblon within dhe vesowree constraints on +Spoee, stime + cost of 0 crtution U He amount of ~esowrtes Mot Ye solution Consumes. saw Opurahions . Dota Host Freyacnlly waee opexalionr ave 17 Tusention: Gua, seeene cwttaed Hoe dato, rush Hy Debebion : Remosing ou onichng retord fom oa dole. ae mn Kecascing easle reenreds exoedlg ote § Haak carts ro 4 averting: "h rows, 4 ese reterrds way Le ip Seasuhig” Finding tne Jocahon of Hue scene with 0 gen keg value , ov, finding Hee Jocahews of all Hee reewe which solictiea one “ov more condkews vy Sorting | Arranging all Hie reeds im come Argued over: ralbebicelle, for chanutlox Lape doba and aasondang OF dedeendiug order for numodend value VirMegng” Combining Mae weerds of differant stered location unto o single shored Joeation whol Ast of Mgovitiom” “Ar olgeetomn 6 a stall dedined sony steps for anbsing a particular problan Ima amd space unad toy am agents one Hae shee won meanwus of the 2fic of om algerittown A goed algortlon iu one whic occupier womory spree oma precod Hal phan Complexity: Te comslere A ow algottnn & ae funehion {or stn Cam Jee vhnkine onder soeege sfeee eqs? tr Moat vitlam “ur Focus of site‘ of She spat dato. But eae’ The wuniauan veluz of CA) for one F Aywage cane re expested value of Hn) jor amy fi Werst cane” Tak maxim voluz 4 4) fr avy powitcle anit Big ‘0': Let, an algorithar and x’ iu de cixe of wep dota. Cleon en ete id to) rae on w taeganes . THE i: Brawn cote Weaose 4) u dou | (rn , ci hl deere of 40 dee ong J, : | One worg Lo compare tee funehion C4) with Hose standard fustions i Jo luoe She funchonal ‘0’ wetaben araega (at): Lek Ha) aud gts) ore functions Aetined on Me poritive equ with he properly Hot fu) u bounded i M ois eto Hla) ik hounded log sour maubliple fre omega wotation w used ben the funehen glu) defrnes 0 dower” beund for the fuvehon fw hota (8) Tt u wed when st ern IG uu brunded from above aud below lag, the funshion gCr) oseibl2 wat erulole wk - y waninas , Sowplezity of olgorithaus The couptordla of an algorithm Mis dhe fuvation flr) hice gives Ane ‘whit audfor Se shoroge -pett waquirawert of us alge “in Jouns of the site wm of the input ote Bq 0 uatodion : Suppose Mu aH elgerithon, ond mw Sc sine of die “pul cal The Compleat 4) OL M wermaser on a luaroasea St “a owls Abe rath u (4) , dows. pring ‘ok vai saadored ee 4 4 Sf companied Us He come ROW sush oo Meg sm, log yw we om, : 5 Linear Sarthe Cowridax oun MW elements Lok we want J seach cu adement “teu! 14 Aimenre scare algorithr a bet cane occu whan He itor append al Abs begining © coma « Iu Hak cane Hue complexity o secreting, uy Fee orden chee "4 que Te sorst cane ocewd when the dim wu Aoumel of Ha oud of He one OF Ww abbsent us Bue odmay. tn He cove Hae Seanching wat Ceunplaxity Uw Me orden of n. Heer, the ov cane Fine Neath of He cxdan : " oC) = o(t) [iighect odor of 4] i Bina, Seale Ff howhous vegyired te from au asscan,. toudeir 4 elemunli valug inate coartle Ascume tall ts ova Ma Ually “un sorted oda According So $e Linasey seardh wolbort Meath. Uaodion redwers HM size ny by Soy, Suppose, Hr wee Mh chenonds in Hee os : Atte 18 Uborodion uo y = ihe. pee = seats = Soy. of n= Ma = Sor, of Mp =H) Hiv 54 Wooten +0 of elmo eh deine Or, Ae Stace cowsplenily = deg Be cmuplenity of Lnay scarele us of ta vdan 0 (%y,") i rics 5 ° sir i Se Rik maternal ——y Bubble Sort : Lek, 460 dust the auaut of Sine vequved B sort an orroy Conkling 4 demads wing bubble sort alga. for liet ys Len sine) ¥ for ie; benet 5448) fo. i. From dhe obove funehon: hen Ls , | voholes (wt) Sues when t= 2) 3) sehater Ca-2) Fes when isnt, | rototes | Bme Biol Hone couplenity x)= (=i) (a2)e -- 30244 mt 4 > aM) we n Th IS ae * tawplenity of bubble sort 4 9 (2) [pha colo 1c] Twodion Sect : tel, 4(00) denotor he amount of dine veqyitved J6 sort on oreo tortoding 4 slements using wsvdtion soot olgerithu. for(i 5 tem sise) for(js icy 5 )>=055-4) f. oe From dnt above funshion : wher tet; ] vototes 1 Hue. when > § votobe 2 Fics wha (2 n=, | volobes (Mel) Haws - Tatod Fiwe, Comaplarcly Hu) = 42434 - + (w-2) + (n-y) RG) wt : 2 22 es cemplenaly f bubble sost is 0 (nt) Chighest oan of ] _ | y , AEM SAS ik BUSA fe 2c a Sdeation Set: | a Let, te) denoles te omcount of Hime raqyived Jo sort aun | @ve4 of 1 clemonls ting secon. sort ola itn / | cua 0, few Ly ire) ot ist d | Qisck Seat 401,405) be fhe number of comparisons wegpiredd sO om ator) coulaining W olenwuts ving quick sort suclrod - Were! cose complexity * he wsurch ease occurs when Hae vce abready “im cotted orden. Then Aue 13 dlemnont required y Comparisows Jo Teeoguine Anak ik temaiwa ws 1 42 shore tee 17 posihon. fiodhousore 48 cublict sill be empty or A Sublist two M1 elemante, Tu digs vay Me 28 2lewerk will TeqviTe V-\ Composusow? te reenguixe thot Ur remains at dhe ont postive and so ou, Hewee Ihe deleh tae compleniba {Oy = ne Goda Ge 2) + 324), ene) x 7 r t PE ee = OC) Tre worst croe complesaly ick aoe “Ub 0 Cut). complenly of quick sod Avwsage case couplesiy Avanage case ocewd when the elewouli OF Fhe we ns in He soved form, In $d care cath. deduction step predutes duo sublish, Hence, Sept” Redusi we Shep pala “4 ores dist placing | clemont ond Step 2: Reducing 2 sublists piecing 2 cements and producing ep kedhaing 4 sublids posing U obewmenks ard paduang © cwblists Henne of He KE Jovel reclucing 2°! eubticts and pees 2 Qments ond produces 2* sublists. Tio wre will be opr. dog ® Jevols of deduction steps. Fodor wore, each Jevol qaasd woes ot mac vi comparison Howse average care compleacity of Hao gyick sort “u oO (ntog ) : . NS "Zo DD O— ———x«m_« -» ~ on ee NA A RS Moe Sort : La, 46) denotes Hw numbot of Cowponisens required Jo sock an oro4 covdoining clouants ‘using morge sort. Accoxding ie he wuorge Sort funtkion we coe He cemplendGof step 1 Jo step uw ordac of |. Re Gomplercity of step ty do shepS ont rasposinaly 4(nl2), 4 (4/2) and O(n), Henee tre finiching amalysis hermes , $s)=F 00) nites OCF 2F (M4 O(n) ofhousise Sine 2 one eoweararcel only akeck dhs oxox of wagnitude, we way dtp He orden wotabion ao feller: « ro 7 eae w , othowsiee ~ w+ 24 (M2) dat, weak, Hoe 28s 24(%) = 9h 94) sokea[e ef] =2.9h wt (oe) ae e[t trae 4 = 2.2K 24(2**) . ate 4d eats 240) eer 2€O) FAO. =akLest) > Ko ‘ Maye n dog = 0 (m4aq) co) Tree dota shuduxe used Jo sopresert ola Defiition Tree “ua wowlimenre Contoruing, Veranelseod elotiouslip Lochaeon eloments. Exomple o O ® SO BW 6 © b OOR® (6 O®. Basic Terwinology bk wode in dhe tree Rest node’ The woot wode Q'u Met 34 R=NOLL, Huon i wrcans She Aree amply - uo child 'w called leaf wodes Lead modes: The nodes Hrose have Parco ave neitrer soot ucde usr the deat Inhrwuedighe wodes : he wodes wodes ano. cabled intoaucdiote wodes. ayaase with all Are wodes below it, Sub-trees: Avy node ‘uw a free T, Je tovprise the subteeas of T. b 5 begree: Degree of a node u Jo the uo. of children Hol a uode bas. Tae. dogren of all Aeot wodes are 20. Binooey Irae’ (Reeurcawe lefwahor) A bina ee Tu defuad an 0 Ayite. sib of lomants, eller undes, se ed “T? wu amply (called empty tree) or, +! (called tect node of 'T!) ond ©) *T! emntoins a distinguished uode Fhe ‘emia odes of 'T’ fom an ordered par of disypined | tree ‘T, Taye @) ® (Q ® © © Sree Sivictly Bi Te 4 " ree A binary Sree is said te be a Stidty Bi t me wode crutoins hho children oF no child at 4 Tt wu alto called Extended Buran dre or 2- tree ‘ Complete Busser Tae A couplete binasy Sree 4% 0 binany Jree Hol og Jhse propentia | mf 4 ty All Jauels sxeopt He daot uv ceupletely filled . TMI He nodes appear ao Jett aa posse. A © ©0660 ,. : bm Full Binary Tee" binony det 'u sad Jo bP & ful! 1) shickly bi ree cmd oll Ave Avot wodes one of Ae < ' Levelt Every uode “we Soe Linosey Sree 4 oacigued a Agua). The Fool usde ui defined fo be at level 0 tk Height: 1 ou He J Ha of Mae Jo ast podlr from tte woot node a Meof. Tre Weight of & Mae aleve avd Aut llosing Ame uM, A _- > ~ >> 77 ted o 2 == level! Lewd D -* level 3 Forma (For Full Bi eae) iy Bio) wo. of noder A= a1 (ue beighl of He te) ity No of uodes ot ong particular level Cory Qo iy Toto) wo. of uodes M = 2X uct Jeo wodes —! . Problem’ If tae Llal +0 of Jeof voles iu 16, coleudote Hur totol no. of vod aud Sue Wedd of she full Viuarug Sree. N= 2x 16-] =31 Rah fe, He 3y4l oe, gh = 30. or, 2 = 9° rhe. folol wo. of wodes = 31 7 4 = fs amd Aue height = 6 ( Tara ona dnvoe drown) algorthant (oll of Ahae olgenitiws ant rertouive): '. Pre-order raven sal 2. In orden Arowensat 3. Post- evden trovensol Ra. orden Trovoual (v-L-8) Step 1: Visit the wade Slep 2° Traverse he Jeft cubctree ossording 40 fre orden dravers Slop 3 Traverue Hu vight Sub-tes according 40 pe order Aravorso).. > worden Tavrsal (-v-8) Stop Traverse Hee left sulrtree according 40 Shep 2: Visit tue node Step 3: Traveue Ae right sub+ 3. fostrovden TRavueal (L-€-¥) 3 Slopi: Travoue dit. lift subtree oesording J6 pest-orien ravers. Step 2! Traverse He aH Sub.tuee atcording Je past- order Aroverse) « Stop 3: Visik Mt ode. Worden Scavensal - ree accoredivt ke inorder Sroversal Exomples ® Proerdx: ABDEFGHC ®) @) x0 - orden! Incorde! peREGFHAC ae Pectordo: DGNFEBCA Q esl orca © @ Pro ord: GBQACKE PDERH QBKEFAG PEDHR QKECABEH RDP Inordese” Pesk.ordert: da Proovdex traversal Ave. woot uode ‘ws visi Ae and cn Past orl Arouernal Hit root uede vicited as! Note Conslrwekon ae M Pro orden: XYEKWVNTC P In-orden, YXWKTNG@ VE P bm ® © oo A ® © Post-ordex; YWTON VK PEX 19,25, 40 B Srorder: 6,10,12,15,16,14, Post-orden: 5, 12, 10, 5, Pre-ordox: 25,16, 1 Sn-ovden: 4,2,6, 11,9, 12, 5,1,3 Past- orden 14,1112, 9 6, 9, 21341 Mole: Nikeou} in-orden drovertal de tn-ordon Arauensal Hare sequewe subbed of an wode 10, 19, 14, 16, 15,40, 25 @ 12, 16,17, 19,40 eee cannot be canahreled as uu yual ao par dae Aeft and right (a (ast) LET wow bina Sree. Te . 22. Men Tu called a bi bd bi aa | search dee (or binas soe tees) if cate node N of T tao She folloning properties 4 Qe value ot Niu ginabex Shan dhe ovary values in Hat left sule-bror of N- 2 value at Nu Jess don At sy volutes im dhe aight Sule tree of N- Bins Seareh Tree cowabrtion keg valuts: 40,60, 50, 3398, "l Step 1° Ime 40 @ Step. 2: Inmet 60 Qe Step 3: Insert 50 @ Stepa: Imo Stop 5: Swaond Step 6: Snsorct € Foal Binary Seale Fer, Mote: he advantage of Bina seal tree 4! stoneling ar stoner iu dime afficiert. a Binarug Seana Tea traversed using algoritinn Shon dhe. Sequence will be a Sorted one. Tit sorting tockniqne ‘a called “tree sort’. ge dase aoe Hoo steps of Hee soxt : 1+ Construct a bina nly tree. DP efeanae de ee Uisiug worden tenverisal algeniiws inordon taversel a Contbewek 0 BST ith ta -folbing louis ound Iemvento, dian © Sun, Mou Tur, Wed, Tu, Fr Sob Atpica Gay ox) HQ @ @ , Peo- ordax: Sun, Mon, Fri, Sob, Tye , Ta, Wed In ordax: Fri, Mon, Salt, Sun, thu, Te, wed Postordex: Fri, sot, Mon, tu, Wed , Tie, Sum © Man, Fi N Hae a8 Ta, Bye, Sap Moy 8 Tae, Aas 7 + Man Felo, Tan Nox, Apr, Sop, M4 Tut, Aug » Pre-order! Hoh Fialy 08, Dee “t qrcordy yam, Feo, Mom Apr Hoy, Tone, Tuy, Avg, —— cap, Out, New, Dee Post- orden + Tom, Fate, Suk, Ag Sone Mog OF. S#P 7 nn ye Dee tow MON: Construct Binsnny Storch ree ond traveue us dares warps iy Ho, 20, paltans 50, 10, 30, '5, 35 (Ao) Pee ore! 40.20, 10,15, 30, 35 60, 50,40 Gacenden! 10, 15,20, 30,35, 40, 50, 60, 40 Q P Rak ordn: 15,10,35,30,20, 50, 40,60, 40 © Aa® ® @ ® ‘YW E,2,D, BA, Gs 1M, KWL, 2% Yeeccrdon: £,0,8,4 52,6, 24 K WV, 2% Sy orden A,B,C,D,E,4,1,K,MyVW, XR Fost olen: A,B D.C, K,V, X,2,0M,5,6,€ Tapesio Te Binaoy: Areas one doe. 'su expression Sree” Oporalors ae nou-len{ wodel oud Operands ane Exomple’ At oo B Coushusl the eapression Hee and Arvest Ta Mvee Wout ty for b-Oqe{Ao/ea Wt wed Je store algeloric oxpressiono called expression leat nodes wy To. expression doen is gives, write doom Moe exprodtion faya/b-D5 {(ase)+ C+} 1 © Towrnamon) Tree 06 Selochou Tree St ua coweept Je eprosent Pee Winner owd bis rag of Bering ee. towuonment. , Suppose @ lowek-out supa eight stoge of a T20 Jowmawent woe Indio a Uke wien The toiwuramont teen will be: trea bi deo ean bo clowe im Arse vot Memory represontahon of Memory ot storage reprosntation of '. So al vebresentodion or veprese poliou 2. Linked dist, nbodion. these urcdiees de 4. Seqpentiol Representation ily representation requires an cote Rouges row $n. Ya uede Aw placed) ab Ki wdox, Hon ile Jeft cba W He be placed ab kt index and dhe right clild ot (2k +1)" wader. Consider te Aolloising binary brea: a A ® © Ree bait of Ae tree =H. > © ® Le Maximum Wd of wode = 2] = 19. Lh We werd an ads wiminu Size 15 to tepsosnnt ©6 GO® na oe 14 ipaicana aly ge ititene erty ie) 34 PEEP PPT ELD Tx) 2. Linked List Representahion Each wade of Abt bina 4roe cau bo deieribed oo Ht usde of dowble inked isk a follows = tee [info rig} PME a Fd “unfo balds de Lop value of he wode aud Heft aud right ane te struedure poinkent holding Hur addresses of He. Jeft awd wight child of Hue ode veipechvely« Comsidan ho Apllowiug binary reo: CB, Te schematic dingram correapouding do Ato tree u- wh, ° peel / (me cetrospending Jinked ist retrosoutation sill be none lt tesla O50 Toa B Hi wre fos TB [a ro | E [wor ress [aso] A | Goce are [oor | D [roe eee0 [aory | @ [ree esco [wu | F [ev Aiireaded Binany Tree (Iu-orden Hiveading)) Consider Jue previous inked Uist vepresovdosion of Aue Sbinawy See. To woe a left and right pointe move officietly by wilting Ae NOLL blocks, some sport pres, called Meread hao been introduced. Fane wre Shoo JGpes of Abveaded binary trees + ‘pHatti-oay » ip One veg. > Mud Mureadivg! Snorer Aovernol of He previous Sinan dre: BDA, E,¢,F fe y) G May oy \ETA Hp One-woy Hereadivg: — Enter Herood He Bight poidtox ox Meroad Jot Deft pointer wv due Some wot . | “ meniory vopraseutation (Linked et veprasoatnbion) of He Mewocled | binany ree eur be done wr Same way: & Tree (Balance Tree ox Multi sq Searels i) _ A Btree uo specialized me ise dee witely word for ick aceoss A Beret of onlox ut (tet waximun wumlbar of children Wel cach wods com lov hoe Moo follows ries | ip Evo unde “ua die R-tree lino wool dildren (ie., masciumum wl 7 key values WA cach uode ) Ewory node Fae ect node aud dle Jeaf uodes con have aflenst w/2 children. (Gia prep Te asp He trae bushy so Musk Ws polls frou Het ot ede fe Me dents ving shart, avon ih o dee dat stores a Ut of ote % Te wot uede tino of heat Aree children if ik uv uct o Jeo{ ucde. ‘iy Ml tue Neat nodes ove ot Aho some Jovel, Coustruct a B-tree of ode S fom Hur follows valued ° 0.9.4, b,k sed ee ie fe freed “4 Order of He tree m=. 7, WAR WAUA WD childxen ude b=5 f. Mapaduur — 4D 4, ay vat nha uede is = S-l= 4. Stop 4: Insent w atep 2: Inserk 9 eal step 8: Trunk f eee fF Step S: Insert k [aeaa*) k] > a KH ao kop &! Lmort A 7 step Inet h (4-b8) Step &* Inert wa i [abd] ph an 4 RES ik aka] BRDk => (abd) BA) Step lo! Dasent 2 7 nl aeade] PX) Tk) hep > Twsonb $ n ad a,bd,e) Tan) Chm, s Stop 12: Trsont ¢ [pid (rea) GD) Veet) stop 13: Imot ; gi ande] [nt] Step tH: Lurk 96 nbsont ato Soa ei. step t© i “ Lie > - wiSo) Gnd) ew) (SI lnswg Hee 4 sep ie mt ud ag SE SS ge Step I Iuot nw shop (8: Swot t [6b ied 1a: inant U ee) a ey fed) St Shep 20° a P Gta vy Bu EP 45) () Gad Ke mel G9 J Comsbuet a b-tree of 40, 20, 60, 15, 12,40, orden 3 te He following keag voluss 20,9, 18, 13, 65, 27,38, 44 22,66 Hud{wion Enending D. Hethuow applied Hid Bin Sema, Fees wills sninimad exbruo) pate age Suppose Ahe ites dot tena ansigned sowie wwaights Delo Sau: A BODE GH walght: 22 5 2 N26 8 Conshrwetion of Hucthuon Ree DB088 Be gy Oe aaae OG Ba : nt we & Be) opti set of todes for messages [ote cael ty oe qi { 0 From eveny interna) node of Huf{won sree, dhe edt ebild U 100 A & ¢ D: € F G H: wi Cowstewst ea. Hethaowe viol wytoo x :10l0 youl x. doboled by he bik O amd da right child % dobodled boy the vt | ras. of Soe feng cle ee , Arvo (8 Linked Lict’) r eet eee ee hive ef hs Sop ques memory Socabion, undivieg Advanlages of vray: ty Dato. stovod “uw couliquows meuor4 docadion uous Pee bane address. So oll Se oto. can ‘oo oeeesced just he wdex numer, siwilon di toy wonoai iy Ag ee wamary docotions ox condiquows, its auvess ture w less, Disodvantages of ray *y Pre-speciied cize* Array stable “ut value, So He sive of as. ae dedasua during eouapile Hue. During yun tiwe ixsmrtion ofSdoln beyond He ving cine wot possible. Again, if o loge voline 4 haelowed as anon Size, and, a few ruuntoos of dobe one duvted, dan Je ge mamory space will be wooted. iy Tnsortion and delphion probleu © Insertion amd deletion of ‘a tediows task o volut inffrom Jee weddle of om iy Availabilil, problem of combiguows memory: H the total vaemion} space required te declan on ara w available as Ane tree wemory bud the womor < one wot vondiquows, Shaw abso Hee ons cawot be deeloud Linked List Definition: A Unked Vik wa chain of chuslwee, called mod, im whic athe wode cansid of oka at well 00 pointou, which shores Ane addvess of the wort node or She addresses of de loot weak oud proviows wodes of Heo Vid. ade date odd-f ry Advoubagas' ‘iy Te u wot neerssarn Jo Lnoro dhe mumbo of dousrls le Rue . Memory ad allocation of (HAe wsuory of ae uw Hime , tan (oe ollecatad 00 and wahon wens ses > Truwdion and dalelion Caw oe baudled 24ferertly ‘athout restuchoung div lst, we reqined Je shore a sodes of Wy No eekmanis mruro Disod vantages: iyMewory, Locks one vet wort mnoua, s' mate ore Suan Had of obnay « uaswory blocks abt uot cantinuowa, 1 Hae et one wede u Jost, Swe rect of Ae Ust fo oseess Pe iy As de odd-rass be ovcossed . can waver be antes ccible iw civgl? linked Ut. Wi Bank. raving it ¥ “jp of Linseed Lit 1. Suuple or Single Linked List: Eowh node cowlaina dota ao wall ah a single Uink hich elds he address of due went wodt 2.Doubla Linked Lists Earth uode contains al ond oo tinks, Frces Walde Boe addresses of Ra precios oud Hu weak node - Agoritlow: Rovense fais olgers vs dee” : ; Gi elgrtion prin Aue “urruabions af vel nodes of TRAVERSE (INFO, LINK, START, PT R) Stop i: Jritiolie She pointer SET: PTR= START Shep 2. Reprok ctep3 and step while PTR#ANVEL Sep 3: Print Me node volus ee oy f nee LPTR) Step u: 2 pointe 7 Cer: i = LINK [PTR] aud of chop 2 Jeep Step 5* Rehowr Algovitun : Count is algorittun courts She 40 of Amends Goode’) in ve. Vist, Count (uNK START, PTR,N) Step ts Trilialize the countore SET: N=O Step 2. Tedialize sue poirbor SET: PTR= START Step 3! Repsot cteptr and shopS while PrR# NULL stop 4: Twswace Courter by . SET: N= Nal Step B Update porter SET: PTR= LINK [PTR] re Algorittou : Saorele Dis olgovitau finds tue oeation LOC of His wade whore Aue TEM oppaora gc va dus. Usk. ORwusise, if seaneling “4 wet suseesshud , ik sats LOC= NOLL “seamen (Ineo, LINK, START, PTR, ITEM,LOS) Step 1 qribiali2e Het pointer SET: PTR= START Step 2 Repeot step amd Step gat Loe if seansh & sussosshed by while PTR #NULE ‘Step 3: ye INFO LPTRI = ITEM THEN set: LOG=PTR ond rear, Shap Wi: Otwurice update Jus poietex GET: PTRe LINK (PTR) end of if shrwshe and of Step op: Shop 5: Sot Loc =NULL if eeonth uo wot sueness{ul SET: LOC=NULL stop 6: Rakwr. Algerittown: Insert at beginning, this al tsk. thr uuonte dhe 1TEM of dhe fist uode of the INS BEGIN (INFO, LANK, START, AVAIL ATE, NEW) step $ Cheek halls overflow ? ‘Step 2: TP AVAIL = NULL AWEN PRINT ©” Overqto cud tun Rewove fied wode frou de available mcuory Uist SET: News AVAIL SETIAVARL = LINK (AVAIL] Step 3 ‘Step Step 5: Stop 6: Insod data ade dhe wens node siT. INFO [NEW] = 1T EM Naw wode will pod dha owigual firct node - SET, LINK [New] = START Now the header will pewh We wows node SET: START = NEW Redvsen. ‘svaet imo suaar fauce] past AVAL ig dhe finch free wonory Lyre he Space whose record ‘w taker ors oe ah He 0) Syshowa + 0° 4 posoting Sy ~ ‘ooo| wore i well ed ————_— Agoittou: Imo of ous Gin algorton ingds ty ITEM of He ond of the tis \ 1 An e lik or iagrke TEM an She Heck node if dhe Us va te wie . gwe END (START, INFO, LINK, AVAIL, TEM, Pr) Stepl: Chuck whettonr ovsdton 7 AP AVAIL = NULL THEN PRINT : “Overton” oud veh , Step 21 Renu First node from Hot available ventonrd tist SET. NEW = AVAIL SET: ANAIL= LINK [avait] Shp! waned dala into det wee node get: INFO[NEW] = 3TEM Step af dee tisk“ olosent ‘uibially , Pron aod He ued wrde aa dle fixst wode.- Af START = NULL THEN SET) LINK LNEW) = START ana SEL: START = NEW Step : Link tof Hee ud node will egundom NULE- get: LINKINEW] = NULL Stop 6: Ini Holive Aue penton SET: PTR= START Step 1 Repeat step 8 while LINK LPTR] FNOLE Step @: Update Ae pointer =) get: Pres LineLPTe) and of chet Step 4: The taat node will point Pre ued uode Link [PTR] = NEW Step tor Rebwor Avars ara bso Semele ag algorithm “y Linea Soarithe iy Brewrey Seovily Tivo worce searching bectuignes 82 oa Wamp or block soantls void worl) tay alee) nm, taunt, Hag =o elvsertyy pratt ("4 How wand lomouks 2"); scant ("/.d", Ber) 5 bral ("\w Exton ote dleuments *) fern, can yies) F pnnl{ (la Eater olement Wai, i+); sean} (“/-d° Lali) pontf (1m Eater aw ahewmoub 35 ceaneh!"); scant (0 .d", Raum) } for (izoy ten, tre) i uf (Catiy= = mus) Lpmatt (om Element found is pectin fd ust) eee J 4 (ieq =20) , pred] ("04 Element wet fourd ©) UE ant (8 Element foun Jal dimes”, tag getcht; 3 BT wasid wus 0) Fad Lon, beg end amid aus Asse OV GRA lm Geter: we of ewes seank pd, Ba) for (05 te site) $ prat{ (mentor lewd 4”, iets Sean (w.8", bali); oP; rink ("1 Enter aourent te seanth :")j seant Cra" , Gnum)s wad = Coay rend) /2; while Croeg <= end) i 4 (armd) == nus) paid (evn qd founel in penton Td”, wesns, wid); break | eu if Cot nead) > eis) j vege midtt 5 | eu if (atimid)

You might also like