0% found this document useful (0 votes)
40 views22 pages

DS Unit1b

gthgtr
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)
40 views22 pages

DS Unit1b

gthgtr
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/ 22
| Representation. of, Ooubiy ddoted bit. too ast Pode. + * * > * ovat j Head | [Nort too! a0 jaco ©7 | cee 4 the List. (GperontOre of Boab tears —— co 300 Fist node & asstyred at head. The Last ell ie we area as NULL, Which thelfeate Creotion of Doubly Linked Lt. JTnsextion Deletion Display Goareh. a rode for double Led Lect. A node db a doubly Jiswed tit & declared wusiog the {fpliouty Ghrueture - Stauct dnode ube data 5 Ghouct drede Preys Stet dnodz * Mexty 3 sthere & no Mader fo the heed node Rist, then the at tren anign the apst node a [ pewrode data = x ams | f Qewneds > Next = NOLL i | Nevonede —> Prey = NOLL i | header = newnode. ’ we want to add one more node th the Be, | then Create 0 Pewnode ard atiach that node to the ent q, the Lfct. bender a s. wu J Now do |NviL| To display +the bfprmation we have to traverse. the clit, mode mode from the 1% rode, ont! the end 4h dist & Heached. * Tf dtoe ie expty then display Empty List manage » Tf the Det & Mok emPy, follow tre Ateps gree below. temp = header wile (temp | = Now) Print temp —> data ; ternp = temp — next; | eee ee Geupking the _Qurnber of, neder ut Countnode (onde header) 4 4) (header = = note) Yeturn © I Ne suite (2+ Countnede ( header nent); slasereo iB pode th sTosertion of doultg dinted Can be. deve ub “three. possfble % Tnsertten i * Position . a “Insestion dip imtermnediat: position. _# “Theestion ap Lat position. s Get the. ihe. Netwnede. ety ges Newoneds. = getnode CD a Th the iist & empty hen, header = newnnde * Th the Ate Le not empty, tren follow the Bteps- Newnrede —» Next = headers ee Prev = newnoede ; 3 Fe EEE le Beles rete ned ere Me] =f fe Tok fe [a Ne loo 200 Trasentfon ip bast ‘pasttfon the Att, thd he Bast cde othe Atte, whose Next pothter Value uh mull. # Get the mewnede sully Getrodec > newnede = getnode Os «Th the lice di empry shen render = newrode. HOT) the Afr ub not empty, then follow ae temp = header while ( temps next | = NoLLD temp = temp > next> temp > next = pewnede __. Dewenede > Prev = temp \ ie poe an a3 we eros ue] 30 | Note | = oe ae ~ 10 | Reo) 100} Ao | 500 Geo| as [woul a ee0 Boo Tse a note at an Intermedia pasition. % Get the newnode uuslhg getrode C2 Newnode = getrte ia) —— fihd the Previous Position P where “the “pede to be -thserted. Ags Rep 2 Newnode —> Next = Pp» next “ P+ ~> ext 3 Puy = newnede Ps Peat = hewnede newnode —> Prev = =P Aon 7 ae ° ce . leo ‘ 21s [ol ee al jz 40] a0 Rusttoe +o fosert an element B the List. Votd iwort (abt x, Hfst £, Position PD q Struct doode ¥ newonede 5 F, Cneuonode | = Nuit) { Newnode. —p data =K) pewnode ~» next = P> next 5 P->Fae vert > Prev = nevonode Ppnext » newnode 4 Newoods —> Pv = Py 4 moo 800 | Deletion Ff _29 pede prom sie List: Deletion mean me 7. my elvonaced ' t ut. “There are 3 pomtble | i) pele the I** node. | ii) Deleting the termediate node. i) Deletdy the Dost node - + Tf the st us empty then d&ploy Emp'y est” * Th the ist Ba vot empty, feller dhe Steps temp = heallews header = header —> neat ; i beader 5 Puv = ube; pe C temp); : ve Free (trp? to | oo lo0} a0 1200 foo] fo Beles a ee at the end. ‘7h the Dect & empty thin display * Zenptye te” a Th the Stet a Ot empty +hen ppttow vi ‘te wep [Ze [224 [90 JN] (90 oD _—_——— Se temp = header rs while (temp —ymext | = xvi) temp = temp next ; temp =) prey —> Next = NULL; Free (temp) ; Relethy a node at Shdterrvedtati. pation ay the Afst fe empty stan dtsplag empl Lice * menage. * Tf the kt 42 pot empty, fellow te FPS @ Get the position op the nodz +o ape Wi Eneuve that te Apesttd pecttion Jt betwee 1% pede and Lott node. O . , [ial ivan Ret | Fibd position p a ie ian Meg 300 Atte next /* P> Pre nex = Ba oc \oo P= Denke Prev = P—> Prev. NL ee (P95 free (Ws eA (6)_Chrentarty Linked Lfct Fain aot A Grutor Akt & a List ib cohich «the. Afeid of the attra dt vende to point f° “hs Adont | fret rode. of, the List. A cheutar Listed diet Aas 00 begloning and no end. Tr i recemany XL it 40 establish a spetat podster catied Ataxt po “| ‘polbtthg to the Shst node of the tte. Tin chrudey Led List Pe Nott potters ave sued- Newnede = geenede oy reader = nevonede %, A rh tha ace & not empty, ppllew the Atps temp = header + lorile ( temp —» newt {= header) temp = temp> next temp—> next = newrod2. 5 % Repeat tte. above steps ‘n! ines Newrnede —> nent = headers, | | (&) ° (oo _jHeAeT ass | | loo 3900 | The Basle operations up a couulay Atogle dined 4 f fst ave fle Rave ggee Shut onde Creation dee povdintn ta A int datas | ¥ nsgertion Gaopudbs pede Fre xe: | | Deletion f Jf * Travessicg Greaiton a Chcutar Abpgle Ldned List uwfth ‘0 | Purmber” of, nodes. ac 4 a 3 TEST td cuatttee (toro [trie Pie Pa ahs doef, hots cef oo & node #newnede , # temp 5 ; a oP Hoitfally we will allocate memory jor neonode | suelo getoods 0 punetfoo- aC eet) atic sed 4 header enewnode ; Pradet—» next = bead L204 Ty the Vote tk 2 then trode & auhped a4 (header) (or) Stent. Ape Create header Dody dhen we hove to autgn Beso to %- Th we want 4o attach another pode to the Reweode fF attr cal getnode (> junctfon, then ansian temp = bead » snctally fe wit change a4-, [temps next = header] temp next = new rode Newnede > next = header- fae cal [i | aoe Boo (newonede) header | eee | f=] $e temp 00 Yo add one more node then ft _ =| | | 1h we wank Check temp—onext | = header ip ue roeans ft move ahead temp = temp—onext. ag to [aoop Ha | too ~ a) 800 oe foal) \ “Teo be ey row j tang = newt lb pocbt +o head node. (Aten; temp -> next = newnede Newnede —> next = header. hee pannel '0 ao | Boo Pi leo “g000 Usha the Same Precadure. Sb can add ‘pn’ number Of nodes ip the List. Sasertion & Chinular Ltbted Let :- There. ave 8' Possible Cases are a fist Tosest x Middle cngest & Last “Insert avollable. fast Sincere : = TH we want to fosort a nede at int we Wo! Seorch [ast node £0 the dist using search CD Dunction. ‘Then that node db mentioned as temp. 18 Le timate? Newonede > next = header header = newnode | ingest a ode at the hast _pasiifon * Create a New node & Sot “Re newnader next to Ttsetf, + Th the tier Lt empty suum newonede. & Go our re fodes hext to the -hent- % Get tails neat to eur newnede & Retin the end of the tisk. oO we want +o dncert a reunode 40 then., |The newneds 40 focen offer Om. p= header i hie (p> naval = hese) Ng -> peat = Pevonede Newnede ext = header Apia uthont we hove ; | co . Piss tee » 20 | 4m id. 100 aco 300 Tincert a node at the middie of, the ciculaa ditt +, | Header. —_— | [ee] ees 1 ¥ aso | M4 Te | Jo 800)-~-P* ap 3007 ff 0 too | peed pd _.| 800 300 loo a2 we want to fngert ao pewndle a5 thbetweer Ep, and Ma then; fy -> Ment = Newoode — : neonods —p exe = 8-7 i | [eo J eader a coon AOS Deleon ih chaulaw Linted list. ) Deletion ok inna of the Cigulor Aibked 8) Deletion at the middle 4 the chcular 8) Geletton at the end of the cBewlar dined Lit. 19 Deleti thik code; +t to delete the Node. | ah we dan’ eons temp = bender; . IE exec iusta chenden = bender —> eat os toae ma next = header — Bee C wang header = p-next TE we want +o delete middle node 01 Ff gared AEE fd next 2087 © fre (OO, ~ plan delet um howe 5 © fx ete, ast meena ” Y = I 100 t : at , Rest ff io ares > 8 B00, 12 30} toe | ot _ too ~ g00 abe! if | j | do delete tatt ode Ma then Th we want vn next as beoder or me ~~ Bena, | TO 800) RSP 100 | oo " g00 7 | Routine - pele opertfon + =" ver delete C9 aR temp = peader 5 , ‘paves A, (temp = = NuELD a orem Pridet (* eit te empty jp, else i abt Guard (© enter are delle data lo"); Kant (“fd & key); deep = Geach Ceey A C4anp = = NOH) g Pabeh (othe node & ot fourdd. IoD; 4 elee 4 Trev = getren Ceoy) 5 Puy > Merk = temp > Mert 5 ponies 34 CGudax {ats ~ The ead node ui astgned as temprode - 2f we fave a Cu then the data wit be daployed A temp —> data. Ut duplayeoa A valuz (de) 10. io then Check rien 7g a an | 80 | B00; 0 (400m P40 | oor | etn bok e i 4 : i 200 ag a mee Thee nett | ade — 400 temp = temp -> next - When Tt yeaches temp = = header 7 means fF jAtployed at the data sh the cdleulaw Uibwed HEE: Fourth - Okplay- Void Afeplay oD t temp = Header ; 4 C temp == Nou) F Pribet (cu empty |"); x else. g wohl. (temp —> next | = header ) BL pet (oad io’ tempoaie)s temp = temp nex > Pub ef (states, temp —p date); 47 ea ° a Lu Goorcting _O._ node prom _tioulor tr Uist = \ While Search, a nods t iol Amted Lhe 7 ue go 06 Compt tne data let each node Ataxt from ‘the bead node. Tp the nade, ~ us Containhg the desttred data uk found, “then Rosi display gen data 8 found Othuswice Astaro Nuit. Yotd Search (dot key) wt fond = 0; temp = header ; D While. (temp <> pest | aheadey ¥& found == 8 (tmp > data | = 40g) temp = temp > next ; else found = (+ % (tmp date = =H) 1 found = 15 Gay J 4 (found > 4 setwn (orp); a else putin (not) 5 _' Cup - aor], gists. [alm ~ a0l4] & ( Punomial Manfpulatfon.”) (n]p - 2018) eperaifont: Sneetfon, Oeletfo epics” ane 1 etfon, Merge, Troversal . aired 7 “ jenecally wsed to Pupresent amantputata. Potyromiats. Polynomials are expressions tontaindes creams uh nen Zero ce - qfeients eaponents. A rafal dk of the frm 5 _ ° . PEED = Gorm + QO EL tan - Th the Siphied Uist representation potas | Tes % asa } ach termfelerent in the it Te Auer Node . Goch rede Contains tree fields namely i 2% Co. efficient fred o* nent fietd ve ibn. Field. faddrese 4 cent oda) The Co-efficient and exponent patd dot. of prtyremnial A Aibked tier Stucture thot Hepresents Potynomfals wath gotean t+ 4ntd srewn fb the Byer head pedbter Boo 100 ‘200 S00 4o8 Stores the | Bee | Petynernfad ABT. | Struct poy | 1 ne conths 1 unk 2% Ps Sete anes > > a Creation of the Polynomial : Fety create. CPety head I, g e sper fad 4 == NULL) I else. Pir = Areodis while (per pent | enwvet) Per = Por 3 nett? ¥ Pes —> next = nevnaded % yeturn (head 4) 5 - Noid add 6) 4 Paty ape, Pevi = List 15 Pixa = Let a; aptr dd # aenoned lavation for “wed ust tmplementotion of | Py a» neupnode.') | Votd diff > { | utile (pv! |onui) q fe nomial ditfexentition Apel, wenewonode 5 Perry = Lise 15 ode = matloe. (ster Cg tmet poly; newrede —> Coefp = Ptv\—> Coch + Pir 7 e™Ps nawnode—» xP = POI exp-ls nuwnode p> next sNvtl; Lit 3 > create (28t 35 _ Rewonade, newt 3 Pévt = perl —p next 5 4 Mat. Bx? Op: usa” [eEEpxe BB.} While Crew = Nou | Ptr] = Tone) t newnede = malloc ¢ Stace, (struct -_ i (Pret > exp == pera —> exp) a ~> Coeft, = pent —» toxfp + Phra 7 Coeth Neonode —» exp = ptr! exp) Newnede 5 Mext = Null 5 dtc a = Creale (tse 35 panorede) 5 Peri = Ptr —ynext 5 Prva = Pera —> Mext 5 else i % (ren exp > pera exp) Newnede -> Coeth = pre —> coxfh 7 Mewnede -> exp = piri exp; newnode —> neat = NULL, Mist 3 = Create ( poor 3, Pert - Peet —y next 5 newnode 5 3 else 2 i new —> Coeff, 4 pera —>eCoehh % mewmode > exp = pbra—PeaPy spewnede next = NULL 5 Mist 2 = Create (List 2, rt Pera = Ptra—> next; 44 35 nade, pe ee een eee nen nnn e nee eo Outpat = i so. 2 Ps Pewnede > > coup = (Pea 43 TIPS (> fe E esaenbe 5x + Ae A number: sa! 4 52° of te two _Potyromtad : ima as addition of He peepee ° Pe ae 5x34 42 2 Gx + an uct [5 [a feat | dick 2 RReewttant List + _5 coef.) - (pera—v cobb) 5h i 4 [ Aaventager of. Seq # SK we dynamic Wiser Can able “to wate chi ub number / * ule can access all nodes in forward direction dh she. # guL unser only cre. polbter Variable Lt fo the node of Sth ooceuptect Les memory SPO than nades of Other Linked Lat. Oisadvar Singly Hintied ist : age & Ves digtiente to acess modes 4 SLL dn backward divection. # lle need fo we taverting O tion ie" a TE us very difteutt to Pesforn ingertion (07 deletion op node beppre. ge Jocttcn ip Sh- frontages of seutiy dined ES * & Wle Can -froverse. ub both direction. Ib, fom Starting to end and a elk as pom end to weverse. “the pred ist * TF we ase at a node, then de. can go oF any node - Dbsadvan’ Doubly boned [AE > eatha. 4% De veguires mere Apart ftd ix Suqulved tor jue 40 prevfous node and next nede. % Insertion and deelfon fakes move He . internation from Siu, Jt & tine Conary process. aT we 4 Te Aoves Hine wwohen wwe Ave to Prat node from tthe tact node. Tt can ai Atop because. dhe. ik 0 need to traverse fo between nodes. Dbsodven cBeetar Looked List = gino than arrays » becouse of + wise. OK. the Ato etused by nei poipters- Coutd end “Pp . # Ft vot traversed coset lle 4 then we. dh an apginite coop. 4 iPte ctply and douily pte LAE, It also doant Appr direct crceersing, of, elements. [rim -aeis] pptiadint ef Aogy Liked Hist Doubly Uried Uist chen led + sort ACK | afmeshardng “ave. ‘at vede, then wwe an: go 0: ary ge te the be. done fp } & Stack Repr *Q ‘ of cards ap a game ‘propieen in operating & Graphs % Undo functionality Agsten- ub Phieshop lox) € Aheored punters word. + cation that: vn paneer have. MRU (Mott woaiteg- Recentyy Used) dist. ay |

You might also like