0% found this document useful (0 votes)
8 views

linked list

Linked list

Uploaded by

sdcodes99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
8 views

linked list

Linked list

Uploaded by

sdcodes99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 20
JANKED LIST:- ps A Sinked fest fe a Ifnear collection of deta elements cabled Nodes. hiheve dhe Jincay ovder ts given by meang of pointers. Each nede t& divided fnto two | payte!- © The tivat port contains dhe information of the element - InFo. & The second bork, called dink field ov next points tied, 3b contain dhe address of the nert node Jn dhe Lic. Tritermation Held Next pointed field | Jink dield DVANTAGE? jae Getaye ance memory shaa tt allecated ft cannot be extended [Arrays Gbbort Stalic Rata Structure] i ; ; a ii) Opercd for. ave cine tonsyming [Thaeedion Deletion Que. ) hinked pst support dynamic data s Because ft user poindey. i) Tneevdion and deletion of node aw eu Gna effictent. Lubes of finked &tsk There ave following tuber of ting list + 1) Singly binked! ie i) Deut! hinkeol Wish: i) Ofyoulay Kinkea! Liab: wy) Soubl Crreulay Winkeal Disb. v) Headey linked Wiad - e 1) Singly Jinked Stet s— Q Sn hte type of Linked Jtet one can meve or ‘averse dhe tinked iat fn anlu ene divecton b) Sk fs the Jtnear collection of déda a. called nodes. 6) Each node $x divideot Jnto wo part: START 7 en ion Aielel tb Lk "ele T L Met poinder shes teed pointer Fielel the additss of qivet node fn dhe Dtet. SXoubly Linkeol Liab !- (Two- way dict) 1) A deubi W Jinked OUk gs @ Dineag collection af data elements , called nodag, where each nado Bs dlivideal frto dhwe ports: Q)An indosmation diele e AKA TNEO (Which cortaln dhe dato ) FORW —> BACK —> INFO b) > polnders qielal Fort (tomlain the eddies of next node in dhe Mat). C)A pointes qielol BACK (eanfain dhe address of Raraaot heen: “wih ibn thus. Srahey ale Feel} ech Ph &» Vavlable FIRST, and the poindery tie the Jae in dhy forward die cHon. ’ eee MAST, and the pointer tteldl BACK travevse the fist tn the backward direction. & CIRCULAR LINKED LY tne A Ddinked ict whore Park node die back to the dink node, fngtead of containgng dhe nul! | pointy dealled Q clreulor Jinkeo| Dist. el FORW havea 88[ 4 Ace] }— foo} —_ + Cisculoy las Jinkacl Dest . | ore \aldt pedi oy a 3 Header binked hists- + headew nede fs a Spetaf nade dhat fx found at dhe begining of the disk “4 Jick dhat tortaing dhts tube of node Ja callecl dhe header - Pinked| Oiuk- (The infartnalion headles node does nat contain any snfovmation) START 7 ea eee Headey «Node. onal : Grounded Header Linkeol bitxb. STA leader Node - +—faa_ [++ — [88] [ec » Civoulay Headey kinked! lat. de WAYS TO MAINTAIN LIST IN MEMORY?~ “Two Ways ARgaye LINKED Ley 4 [6 [2 [io] Lee a ey Qa Add veda nm MEMORY REPRESENTATION . OF = + 3 ie 8 oe THOIC 3}-fD lo} JE BIE 4 Null [1] PATA NEXT START HA [44 ~ Rly 2 ! ta 53 [D lrol. 3 ye he dok ita “Sl BT. # $0 the net deta Ix stored ot advo a = is at odds en Sha. “sql [a4 2 | HThe comerpondi ng cst Fla] .” noxt atore dhe - --44 Et addts, o} nowt node which Tk +. graee “Slo E Qs ATA [Next] Lt _ mn LT C0 sre A BHIC BHT as ie sage 4]. L 3 % rn ate 2] PLS TT set . o ee} To gE ; g Bs} F {E [0] 1b} AT x lol Gr_[ 12 2 5 5 - al W N 13 iar... [=F 1h 15 2 z a ORY REPRESENTATION OF ously LINKED LIS x [A feof—Yor [8 [axe har] C [oa — Boo] © [x] L900 200 300 500 rev [oat [Nox] x 200 300 Soo} e 200| 160 300/200 e 4oo| S00] 300 3 boo| 4 CIRCULAR LINKED Lis qe 46 [2000 } 450 [3000 60 [1000 © 1000 3000 2e00 30 CIRCULAR SIHULY LENKED LIST 7 Anal dinkeol dust dx zirmlars eto the nro | Mk At : pointe e at oe Int ‘nocle of the erreulas siriyly. Lire p00 [4[20e FF 100 [33[ 300 [00 aH [oe ergeurnn oueiPuneeo usp 30° Chrayiay ae linkeol {irk 1A the aimilas to dou inkelLyst ee a dit Lot node 13 portly dofial node and dtr ola b node olnt cho che last nde. CREATING A NODE:- % STRUCTORE- 4 shucture tontaine a vnimbey of dota dyes grouped Uogerher-** collection of izsimilar date py.» Syntax: struct book char name; float price; St Pas 45 shuct book bi, ba, baj by nang by price, by Pager ®R? [130.0000 [eso] 65518 6S519 65593 b> Sel} Refoventin) Shuctuye s- Self vefeventiaf Shuchie fx a shuoturw whieh contatnr a poindey to. Q Structure of the game dubs. Syn - struck abe a Q; char b; struck abe xzell; OTE hl, wf upedl self referential chuchire tox creating, a node of +he ae Diokeol isk? NODE REPRESENTATIO} iN & Node Je combination of two different ‘bypes into Q ig sa : NODE We will we shucdur de combine 4wo dit}ovent tbe into zinglt dybs- be Creting Q chucluat -fihich. rebreaent: the node- Sed} referential Structure. @ struct nede Si ale aunt ee membes 15 ti buF Toul to data ype member; data date posible, cheat ‘node stinks | sink CREATING A NODE INC + Snclude < stdioh> HH fnefuda ¢ stditb-h> Struct node L—+for call dhe malloc fun int data ; “nede. chruct nodg stink ; oie 43 Ant matney Shuot nede thug calito: fe -_ . = 4 hud (shut node +) malloc (sizeof (Shuck hade)) 5 TYPE tattinge el | MaUloc. fx tulbin U to create ‘ anode, and Mentary $3 allloccteo|. [ro00| : neces ala JinkQagphead : t head daip ct _ uae oF errno ‘ithe head ean ge Male the node . + heacl-» Sink = NULL; pint (“ 7s0l" s_ heacl — data) ; Misti ae PROGAM TO CREATE THREE Nope: [1 Method] # Soclude ¢ stdio-h) # Snclude < stdpib +> Shuat node { Ink datu; . Mole x Link; Gspnou] fe ) eo nk maly( ) 000) yoo 00 shuct nede. shad = malle siwof (struct nod) hueal-> data = 45; one © toad» pink = nut; oh Dink, bind c Lor I : hut nb) i Qo = malloc, (ping uct Ny Of sal etdo|—> daly = 9 gj the disk ned py heal au = NULL; [45] 2000 } 399] Nuc 5 a 1000 2660 Joo Jn this ewe aT hea 2600] current no way, +9 acre [Ror] fa tuad. Struct noe xeurrentt = malloc (xineof Cebruct node curnenti—> data = 33 CuNrreAtL pink = Noi; cCuNrent=> Pink = curents preity (” Add *Ael", tool daty stumert saat ennai vetuyn) Oy BD Rein Linked Yypt created Lik thre we fpleete }—laeeo} fa roc (3 [AvLr] 3000 = i p= 7 96 a, =i OPERATION(NLINKED LIST ‘— There are ol Jouning operations of dinked Jikt: As L> Searching . Ly Ingewdion Ly Qeletion LS Traverain 1 Access each element of dhe Linked ( viet , exactly. once b> pre gt te a pointer vaviable _unich points do dhe node that & eusveny a paoceused > LInktere}—> It points do the next node fo be $ processed: thy the aaajgriment PTR = LINK [TJ PTR ae Sek ees ‘PTR = LINK[PT RJ 4 | +> Algorithm: | Q binked pst) let LIST be a Sinked fist im memory. This af? averte) hist , opbying any operation process to eed element of L267: 4. Get PTR= START [Iritializer pointer PTR] a Re peat stebz 3. ancl 4 while PTR NULL. 3. “Abby process to mea (PTR) 4. Set PTR = LONK CerK] [Eno of ste? 2 Loop] S. Exit. ee to create number of nede- #. nelude,< stablo-h> +#include < conia-hy Tink =(shuot node ¥ malloc(sireo} We - node print} (” Enter Org nots s : Scan k (%A", Pink—ddata) Unt data 5 Ricca i Shuct nede xnex j It (head==NvLt) 3 \ head stemp= Link; Shuot nade, -xhead ,>Jink prlemp,] le int math 1 yf Sank CHa" #chorceys fein nerk= Sink § Juhl ly (cheice ==1)5 emp = tembshexts Shuck nede *p=heads 4 ube (p1= NULL) Point (Enter one tov * ’ Int choice, ; da Paty Pecay A os dala)! in exede. anal POLYNOMIAL REPRESENTATION :~ (bp « of it) Talunomial ; :Polynomiaf ig an expresion with m4 ferme. %) Each tem of a poly nomfap hat a coefficient and an exponent 3) Exponent mut be a +e hes Sm en ae apy Exponent: Coefficient Tesm 4) Each term of the a wlll velsrtgent: » nede. Synigx- shuet nede Used ginaly Hoke! ¢ Jist nal float coefficient Unidjvectionef ) Sot ‘xponenb; Shot nodg sine § ; feo] —95 TST} 93 TS} TTT To] 4000 heac| 7000 Joo 3000 Additfon of seiemie! “ Led ay we haw two polynomial Set da+4 Y— pata +2 ——fii) s Addition of two polyoma involves combining Dike_}erme present dn the two pabymornad. Means adding +eama heving fame variables | Qnd = game Sxbonents. | OF ser® pon 41 Boe yo: derma ave arranged dn dextendtng ovdey Pocedure: _ Beh + 43 | ob they exponent ; 15/2[-+—Jo | ++—I"Jo x] ‘ hyeelt + cs [+--+ pe] eas aay ia ae Q Add sxe4+ext+o2%* ——) Boe 4 3x 4+ a4 5 —i) Subtvaction1— sur +o" +4 —W @ - Be se oO. ay + = i oo | Lee =? 430 =1 ie iid ae a= 3} | eet ep} Sn} 2b W +2] 2. 3[1 -t Jo [x r I era Yultiplicabion ~ Concides dhe polynomials - gop sty aH) 5a +L + S—(I)) beach der at palunomialay Must be roulbiplied with géeh ha Polymomiad ci. every E> Multiplying “each tam memg tll ng del ceerfitients and adding Hui poner. x5)00% arya @x5)oe 8 (axs) x” ne" $(BX5) + yy a * By (1x9) 0 wxsye” > gore + 28244 gnc? 5x4 2iv7 +9504 52 +9L 50° Slrov'+ 51%, o9c0h goa” 2004 ost 150%, FIBXLP+ INES i inindneeiegis wile aS (Resultant tmomiag ) Qe 4? + ay? +1 eel) 50! + 7x8 +s a « [ESS ts ery [Smo heads 2 }W— aay ley 2814] spas i SoS eA FET Pine} et hooals , Syawbacks of -Ainkedl Ltsts :- Ab fandom access ts nok, allewed. We have | +o access elements sequendtady hosting vom the vst node (head Node). So we cant use binavy Search . © Extta memory share dor a pointer it vequled with each sel of the Jist. e

You might also like