Download as pdf
Download as pdf
You are on page 1of 9
ASSIGQNMENT- 0} ARYAN KOHAR SINGH 4 (ener) ) We have au nwa ?A [a 2o][4... 28) Vl Goo 100013 ae 20°143520 4G Ne ag did «2h ose-e LBizaugi. 20 Liz 4 yg; 28 Base Addoess - 100 5 Wea “Se Faw Mojoet, Add (ACID) © Bone(acll) 4 ¥) [We Lbi) + (G-LBaJ) * 100 + alas cies) Gj pati 26 4d 1] a) -)) = 2 [aie abad ayes ° = BOLE ONT 4 hg, Gry] =so04a[e6i +26 Wd 4] -so01[60i +95-52'] ©2)@) © ASYMPTOTIC NOTATIONS: dhese ave Uhe nolations dogencsale dhe wedation Jetween dhe duncticns. Examble! x ¢lixr: e840 ge: 30249043 Be 3 3 1 > q 2 ¢ 17 : . 1) Big Gh Notation + 4] suppose dheve axe Jwo functions tx) ond gle) Gheve. CX) $e: Ger) qeora 7K where k=0,4,23.---- then JOO = o¢gtzx)) Fg. x Sth= tes gerrs Wactroxed ° i 1 i 2 5 z 3 13 to “7 Stee) $ ¢-gexr) Cferom dhe above tobte] oe jo = O(gtx)) W) 'g: TReto Netotion | 4 osically uiebsiesenls avewiage case ¢ complexity he. Ctx) £ t*) £e9.9(t) ea: (oor: Sinz t+ bog ° °o ‘ 0-037 0 2 +034 3.010 Jeg 2 Ct) ond alse other vald O) ¢ un anlich oes ge), 2. eget) Ja) 4c8g*) ae Sn a W) Big Omeqa? Notations 4] Supbose dheove axe duo functions Joedand gtx) where Jt) % C-gue) foo all 282 i where ro, 4, 2,3.--- 18 fon = OGL) Eg. x Jeo: 28a 2 gues 2744 0 4 5 5 1 re 5) 2 410 3 23 d “2Jlx) % e-gte) [Jotom dhe abeve dable] ° SE) = A (ger) & Void Jun Cintn) inti, 3, Count =0; Oot Cis mjozi Zenjita) Seer (i= aj S4nta Zen 554+) deo Weajk denj keke2) 3 Count ++ 5 9 @) ko= @, k= 4, kos 8s Ks= 5, kus 4 n= 6, Gr: 8, Eo: 5, by: 3, Cust Lo=40,t1=40, Lo=@,L3: 6, Lu =40 FKow MAJOR. COLUNN MAJOR Add (BRezes3) = Base Codd) Aad (BB cxa57) = BaseCadd) + + 0U(((cous Bia 8s Eu] W[Ceatg + Gadte 4 Es)Li + i) Le + &)] = 5 Joco +4 [@ase 43)104 3)) = toons al Gt : +5)1046] Fooo 4 94948 = 101948 AdF904 " OD We chave, N= 20 and N= 5, W=2 Bos Magee COLUMN MAIOR Add (Monks [is][4]) =Baseladd)+ Add (Mase (18JCa) = Base (add) + ean WON G-18i) 2-83) W (MG- LB) + Gi-LBi)) = 30004 2 (8 (1s- O87) Sharse Mateix: A matey shoving dhe maximum numbew gj zere elements dhan dhe non-zero clements is aalléd Spaxse mately | b& Complexity is dhe €ljiciency G4 on algesithm . bis measuned io fee Feams: oy aytime TG] (9) Space [es “Kelatienshib Leroeen time and Space! qawi de 4 [spoce- time tsade oN). a Jes) Je) 3 4 the numbess from 4 te100 eer examble. 4) we thove to Pair 3 8 4y---+, 20° nen 2 23 Byer f Longe Les space SPOCk + Algeaiithm Swap (a,b) Space J a-l bsemp20; bet oa temp-l b: temp; aes 3 Funye3 ou) ars. “0 4 3 ey 08> Adgouiithm Ji lo add i a Aes ue Polynomials using dinked dist. oak ie Polynomial Piand Po wepresented as Jinked list. oe 4 _ wound al Values g} ulnked dist and qullow Steb 2 8 &, : e values a}a node is exponent is guieater i , x copy this ovep ut da and ead Jowands thenext ao ork el ‘J the values oJ bath neders exponent is Same ,add the coe|ficients eo cond then capy dhe added value with nede tothe wesull . ep St Print the uresultant node - Step 6. End, ed dist in which dhe disst and dhe das ey Aeinculan Jinked dist 1S 0 dybe af dink nodes ane aso connected Yo each Stew to qevim OCC - (@) Cureation ¥ dist a nodes by Anseutton qfier 4 Specified nod e © Delete the node aba given bosition @ Soot the dist according to descending oxder. © Disriay oom the Beginning to end. ?) 9) Gq INSERT ELEMENT AT BEGINNING: { Stowwek dist * new; NEW) = malloc (size of (Struct list i} Giana) u vet Tet) 3 Pint] Covesfiow")s else New, 9 injo =item; new 9 next = node; new, > Prev Nodes Prev," node Prev = ned, ; node = new, ; 3 W)INSERT ELEMENT AT END: (stouct list knode,* next, 4 pyev, Chor injo, Hem, * Pty ) Srowct dist He} new: mallee (size o (Struct tist)) i\ (new, = = null) { Joint Clover}ten "); “else an 3 \ojo= item; Ply: nodes while (pty snext L= null) { piv = pha next; phy a next= Neds; mew, > Prev = PRE; news Next= phranexty j (QW) INSERT ELEMENT AFTER GIVEN INDEX: Stock di (Stowe dist 4 node, * Plr, tnext, + prev, char info, item) Stotuct Jist + new. ned, = Mallee (sine ¢ . i; Stat 7 (new, + mall gy (stave list), Point ( Ovex tow "); 3 else New, >injo: item; Pls = node; bile CP 1= loe 88 pia snextl= null ) Prs= phe next) New, Next = Pry s next; (Pty 3 next) 3 prev = new,” Ptranext = neds; New, > PkeU = Phy; 3 98) Advantages ¢} Deubly Linked List over Single Uineed Uist : A DLL can be deraversed in both Jovuoaric) and backward didtections, jhe detete obexation maute eljictent Ja pointer to the node to be daeted ig Givenin DIL. We quickly insert anew node belone a given node . & ARRAY Linked LIST Q) Size a} an anwiay is Jixed. a) Sve 4 dist ig net dived. @) Aotwiay is a collection ® Linked dist is a collecton a nodes. t homogeneous dataly be. Memory 1s allocated etomheap, @Hemory 18 allocated Jotom Stack. a ; , so dala) Linked- dist woctks with dynamic data &) heoay wortles totth Stake aware Stwddre. © Hiements axe Stored in contiguous &) Alements can be Stored anyohere memony, Lrcations. dn the memory , ‘1 $ Og7 Dowdy inked dint ovr dino shiny dinked dig in a CHliedlen wrowe hareg foevious, infu, nevt. AbPlication UY Poudly Linked List: VIS used ig the Rovigabion Ayslems whee cfonnt ond dite Wine otequived . ‘ @4his also used lo wlepaesenl o cansie Game Sere a en 46, ) IEIS used by various applications te implemen’ unde und minds lures, a) Dour Linked ligt 16 also used in Conateueting HEU) LEY wane ; ©) Stacks and Nash Tables con alo Se cangeucled wring hl DELETION OF ELEMENT WAT FIRST NODE: DELETION AT ARSr (Stauct disr 4 Node, Nev, x peeN , CN ‘i (node = = null) { point Cundey}leo") , else i temp= nodes ino; node: nodes next ; Dede s Prev- nul; jee (node) j 3 3 @) AT LAST NODE? DELETION AT LAST (Stouct dist * node + next, Plz, demp, Char inje, + Sov! Z 4 4) (node == null) faint (“underjlow"); 3 ese ove = Node; Pty = nodes Next} while Cpt} =nul\) Sove= ptr; Pty = ptrs next, temp = pissimfo > Saves next= pty next: Grree(node): , 3 3 0 10> *tinclude éstdio.h> Rinclude éstdlib. h> Struct node { int data; Stsuct node ¥ next; 3« head; Void iniatize ©) { yhenaeno Vaid insert Cint num) f Stotuct node t newNede = (stwuct node #) malloc (sre CH (struct node)); new Nede > data= num, newNodes next = head; hhead= newNode; forint} C' Snsevted Elemenb: /.d\u" num) ; veid clindloch (shruct node # head) § Bruck node * Slow, * fost j Blow = ast = head; hile (Slow LL dost 28 Jast> ned) { Blow = Slow 3 next; ost = jost>nen onerts g i} Cslew = = gas)) u vint} (* Linked Usk con eR Ny : D Faint ti! No LoeP iP Luniced Liat \4"),” glist (Shuck node * pede Ph) f rains a teop\"); s % veid Print Linke ‘white CnedePty Lenu){ fooviny} UTA" node Phy > data); node Ply = node Ph > next; VW nodePhy | = Nutt) int} ("3"); int main () £ initializec) insext (8); inseyt (3); ‘wseat C9) + insest C3) insert (9). head nexts next-snestonexts next chindlocp Chead),” wtehuin O; 3 Ourpar: Ansexted Element . 3 Anserted Elements 3 Snserted Blement, 2 Anserted Llements + Thsevtecl Elements 9 Lanteed List contains a loeb. sheads ney) }

You might also like