0% found this document useful (0 votes)
54 views28 pages

Ds Assignment

Uploaded by

zwupxuw8e3
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)
54 views28 pages

Ds Assignment

Uploaded by

zwupxuw8e3
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/ 28
qT athat Ps a poinden? Assignment -1 | wre, —_|__}_ a How iE can be dang sso? A_pointer ws sible wshich contac the adden 2 —— | Fm memory 0} another ved ble. ‘The +0 most-fenpt: — | operatort_ wird lofty the pointer type ase. | feu Optraton 4_ushich giuts the addon 0] a a Veewable - ee —_ - - — | be ndiyection ow cl tng Opucatore * gus the | toner the objet pointed to byapaintot as alion _ a : n int 5 tpi we pie gts i 7 boinders Can_be A US) _ | pointer can be wun palin ae 4s'in Jolloi A Pointer Can be dangestious wher an Aces On Cu ol memovy that Doetther out Of ange the foiniow ae don q 0) bu that dow not Contatn a potest telorence rp f ugitimatr object. ' * - 2x: maior § a sot tps fot pastos p= &pas - pouty (" Joa" *p)5 - 2 foi ( ~ad"*(p40). a tohen a Nut pointes iy da -supeseenced becaue on Some —— tom pullin %& elu A_pprsumitting execution —— 3] ~~ ening Gelutten pointer types. — 4o_ Cont nur sox it may rebesip she sade Sorted tn S9¢takion Zwto . fo it ond produce @. Spun OU Pointer is dangoxou when “unt 0] cpl! EAype cou 2) Pi = malloc (sizeop Cink ys B- Cat pis 4. Tn Some bey pare:——|__|___ rez: m_.porntouy hae the Same size cant pe nt Sen int fs the dajauatte not Speicher ‘peters Sorne pHiogHamm ww omit th ral netuin hy pe_when celining a runction. The secon, ype att foint which can_ oti be ‘inbespsuted as atpdintor: 2s hit _ct_pote on Atiuslure with io Abudtwre with an 7 example. — - _SBructusy ame « dyicad ed, Stpeorately. cand a Vaxiable _ _ e Sbtutune ty Wt ty dvdovied fnside ta cai nt ion un another Sig = The atreving 0) the vosdab! om 7 Abiuctute type that au ousted ‘nsicls crnother Stedcbone [tothe Same, Way as cecuming other mernbor — —Stotuctuwe. - senarne [rods jot toa selon Atte dob : _S humen Being & human Being pawn | OO cthe Com Mion OO Abtuctwy “is plaud instcle the junto Be ition fhe ol anotha Structure . pe ae ze | ear JJ ats chart mane Lrod, Sntage float Slane a Shut Xu int mont hs Fa day + sewuntial Sbiuetune Ls one in which on or mone 0] 145 Components ts a poinior to idsely Sell = vulerential Struct tually suqubice nant. Storage managment Howtios (matloe Bod pore, + | Explic ly. Obtafo and seleose mamory- —— id abet a Oe than dala + a | Stet tink | 3 Es ——_fach al votive List will have dati and link. Bala “iS. a Single charactor. ——[edinks Lok ts @ pointer toa byt Sbtudwe “he >t Lan Fnstance of Lut py 1Ae nut pointer Valu O| bink #5 ether the actders tn _memoey ol Ust emt Sem a. tem 3 5 vt | emt data = lat — pere:——L_|__ mses GM be cv [| Sturchores semi ited and tlem 3. rach Contato the Pdlata them asband c. and the null paolo thuse | AGucuw Con bt attached -loyether by reed fates 2 die mull ink fidld %o Tend coith one, that panic’ | Hema and by 14 aUnO the ratktok fete in Tem | 20h one hat potinds to “em + Html, Ute = g Hens 5 Heme link = film 3s Te Peel namie rosmory allocdlion wilh Example _ rapotant: task fn cornpatii yee memory allocation ts Cee al sun -Hoie - No need ta know Size 0 oxy _podor to alotatzon - memory 2 allocated ay pa 7 7 Maquinment + ty. linked Lot 7 | “thane | axle owt junction + ne 1+ | Matloters ai oct a block 9} murnony peLt bs used to AWlocate Mnemeny Spr ce I pox ws ern _ _ Pundion locates memo 4 seohwin. a@ pointer oy L _|_stype Noid 4 ts hu stati | that me block» rena at Eales Nat recone pointer stoned ie not muh ae a ‘On ee oe rot Hale, the mimoe Pattenden dwuina gxcartzon. Th Caras arta eral | @ inlay s- a q Tr 7 pte: pet): enalloc (Sze) ph- painter vost ble o type cata ype « : dlateu — ey be aan LC type Cy = no, of bytes gugjusud - bore J a) tr tat sets, — 3 ples Got malloc C109 5 ~~ e+ | Calo. C+ athnate eneuttiple blocs Of rere —— lett ty Similars tomatoe beck TY} intiate Bho the allncatie — | _ memory 40 Zu0+ a _/L Syntax s-_pters (data type ) calloc (ni Size). — | nt neo} blocks te be abla fs fp = calloc. (.20, tye of Cink’) + This Junction com) ere bred Jou Po%2 | byte Cape tt) = uo. byl of rorinry block, 9 co re calad- , 5 | neato ©95= tued +0 ne e Sige allocated block by malloc C9, calloc ¢ Mew Sige » Me q aluxoted memory can be takes wing 1 online ¢ 9 tamale be used to Hocus the S59] abuad. aUocatied maceny.. i Syolayi-_jottts Caatatupe +) rule | Cousia = €qr- _ Chan + dtr %, St = (ohesy)) malloc. io : Sbt=_Cchax¥) rutloc ( she, os —]frueeo: dealincats the allocated mmeengrey which was done. wing malloc 2) catloc or sealloc 09" - —— | Sqoote: "pus (_pointorname D+ 7 “_ocen (Sb ee oO Shows how one and tao bow fonal ao wouy us “allocated Ay namnically , - + ds fiona} ves Jani toxiiting compul ‘ Lotion where — vi | So Phene ond Solution to this poeobleen * to dle jest thin | decision do ruin time and allocate the oeray Loken _ Wwe howe a good timate a dhe riequined Onin Size » Ff xample — L Set fn Pat - — pedal). (* Enter the ce al neembtoe ogieowst Js | Sean}. ("feds £n) a | iM hoc itt — oe Thue henun sional fesoroys | £3 Uy aot nfo _heprucnt % vo dimensional Cao bs. Yecpreentntecl 0 4. e-dimensonal aeray ia | which each element iF Tel) a tne-dimemsonal arora - _ ex: wot xt, fey O35 cy Cad cy | x(olf xt3t - xPIL_ oe ee xi ty] $y Jobat acening, the pointer in xl Hudhete x0 P= ati Size | Ne (int). “hich gps tte adding | op the Zowlh coment ht Pow po] ite pee _ xd i= Js atig size 9] “Cint) «xj a A+} *Sise dint) xj Je XUTHT 4 Size ql Cnt) ‘] me ee 5 | _ my oot (23) (4): é: ore “| fot a make2d ovoray Gant Mow, intzot) tok xs malloc Cx rot # Sig. x); jon ( gens +4 roalioc (xij, ole fe Sige Pe (RO) Serer _vetusin Yop oe I Sparat_reats L rmailsix ie napsusrnfatzon — A.) A spose, matty fo mottuty whith har mace number | wo démints ora Meu ews neo —Zux0 Heese es | Yon be a 10,20 te. Les ot 2 3 To fo hole loli2 jo) Olaelo fo] ue] Oo. 2 a s tT Lo fas DO 2/vfo |e]? | 7 3}2%/0 |°] sv — Disadvantage : - Fy Sposut reotiix Contain many o'4_ qh We Oe nrartipulabi ng | only nomn~ 50010 Valin then we Axe Lysting tha _Mmernrry pate by stoxing neces onuy _Zano volt « this can be duane by toving ba ROH-gew volus + _ - _ HE dujine Minx 100 cope) hast | Int now 5 i fnt Col, e Tot val — Tem 5 | Teno (Mar tens) val> ar F i Functon void suadsp mata (Tem alidatm jot n> q JOE i joi Cte) + ALO]. 2 =m, aloj-Wl=m, Ke!" + (Cizo+ 1m 3449 oC feos jan yt) & . < tes , Col te a — fatey |s | 4 | 5 ol4o} jad |o | 9 | to | af?) fb | 3 | 2 lo a(sy |i | Oj 0 afeyt | 2] ?2{ 1s afs3|3a | © | 20 af{e]_ a} 3] 60] — alajy GU] sf} is} { ofe} 4| 2 S| Sean. ("td 4 them’): oxra,__|_J, on How Binnpaing Spuue maby clone, =n we A mabrix ohich ts eid by hanging seo ebmentt Se goto column thmnt and ude, unna iy Called trons a fu a maby : pose Spore nati “Ha nspore m Typ, co] val Ron. —~ fox] s | 4 | 6 hoo [4 ~~ lad} o |e | to bOS foo afz]|_ © | 3 | 4o ble) | oo — bt} tpofe} eso} o — bral fo foe} fetof —~|acsa| 3 [Oo [20 vfs) | 2 (| 21s foo} | ble} 3 data] 4 fe fic eta] 3 | bre] uts fas} | ela 3 — _ 'o to | tt {o |20/0 ' . oO | o. 58 Is 2] 0 |22/0] 0 of [3 | sole [ol xfest Void tianspox Crum aly Teun 623°) < jot Tagres ee blo} -vow =afoy- ls, _ - bo}. a] = aloJ- rou", a - bPo} - val = aloj.-Vel+, kely _ jou Cieo 0 4i ee stHincludls < conto. hy Souk date ink mm tdi yys oD Pe | stu employee ~ Chou earn (50) 5 tect emp-td — | = | 9 > _ Sen} Cred = thd = 7d" od 6 &005 - -dd , f Dos. mr = [gies | it me tot ts . Stocud™ Employee: ion ebtsoos _ pedot a Vendor. name 2")5 - Fong PfoS" shee came), | pout. Co Anetoter emp-i id. _ cond Cd, dee ae ty CuAn enter pate o Joining \n' "Ds pent] (dd meu Ds, —F ger YY, pitinty ("1 Enter patio) Bivth \n" ru peat (" det-mm yy) 5 __Stanl["Yed A ods § pow. yy). _ punt ["\aname */ 8" e name) +, pecat C ‘ In employee ID ted “eo “erp ad: puinty ("V9 enter bos Ted Hod Yd", UDOT vd @+ Dosemnm ,e@- P0549 D5 a piint) (" Eoten pow vod Gal dd ¢-ros-ccly C006) moo, es bo®-¥¥) + gtchCo:, B-dd fee Bow stn som, de that sc polynomial | Apply appropeale clata structur to supresent tevo Paige and wets a fyndton - to add He polynemtal a poly ronal doa Suma) im where each Jom her &_ form axe wero to is ae uuciable ais the Cosy isnt and _@ is te Export”. _|Repraunlatio Os. pee: L_|__ rae ACK)= Bx!P4 oy 6 oa Bd x4 rox3e fo One a cb ) scupacesst polyromial. ts ch te use ypecb, Hecate hype polyremial Aelyin e | MOK adigvee. 1 Neste Suc a — tga — a looct, Cah tagrecl- — The Pouset toate ane Alkenatz sepeatal Lasts Only one global: vey 7 ¢ The Cdaclocateon ¢ add oes May TERMS too - — : get Stocuet. {loot cod int txpon 3. polynomial - a polynenial eons [napx—tenms'}, — fret _avail=o ‘Pelyoemnial addition ¢- — € €_uncion 1 iS We +0 oblefn P= 14+8- TD produ _9(%) Pac Cis eued to AC) € BCW) —iMem by town | Stating at patttion avail | vattach (> Hract-cdldle 0 pol yromial. A 8 __|Nowa Noid padd Cio Stasce A int yi ish "08 Gab B OF inishs nit *stastt Dnt 4 4i7 $0) —\t wy | gloat coegicrot . — oor | F StrettD = wil s Stool a xCs Sad A ottath (teem [stat A)-Coy. trum [ stad AL expan Jon C3 Stare c feAbhOs slater) 7 % abtach(teum [stank 4)-0ef sfeum[ stat} 2 xpon) 4 letenalsinrtel- orp [Wha ty the dijjgrunte bubpunn tne ta andintals]and 0°02 —f_int ta_% a “pointer tp an intzqe it manne that 10" _tan_ Stone the mamorsy adds ofan fakes ———_Meviible : 1 a Ee | can Stove 7 Mnsecutiue indgnw TA memory - “sind [SJ 16 OH @otar 4 pointers tointegon. Th man, LF that toch elymnent in the aera can Sort a mun Ladcbass po) an “nh Vasciable sMoclude < Stetrony | Tot marin > eS Tob num = 105 int *a- g num; proety ("value O| pam ; td", ads, fot bISJ= (12.3, USYS Ldor(int ts0,325 5744 yw? Tat C= 005 tnt A= 2005 int e- 32004 Sort prriAroiel: TEC gd eed 3; forCint i: 0 si <3 57D ¢ 7 eee oy Perey! Value of inctey Yd Yad ta Pep fe) yetwen Of 5 ~ OP? Vokes ef num: to | Vole aipatont | Fede to Tedyo 5 | Wadi 3 = 4 | indy UF tnd 3 100 © treaty ++ 200 _ indy 2. 300 recesses part; —_|__J_ ras Zara VQ) unite a Program io & tovead o Spa matyiy of integ a4 [Valtus and Search thts maby Jou ebmant Spreifiicl by the Cf et - a — eMindncle 3: | oii —foutp EEE Numby of wus 3 ___Numb ora non-zero uments sy _ Bol _ 112 aes) aia Stastch for the cument 3. eument Syound games nxre: |_| _ mas. Ap.) Mite. any tivo palloin matrhing acd typlain with frarnpls — pe | Noid foih C chase pat - jot ne abiln (Pats — Fatlune Tod = jon (jts jens jt es, SS = - 4: Fotlwu God) a while Cpat C73 t= pat Gar} iy i >-0 0) F = failure (p)5 oe [Prat (gi = pat iy failure Csi s Ue Kailua (2-15 a “int Pmatch (chan ’ shying . char "pat _) £ - _ fit eos {205 : int Lins = Stolen ( string); - fot lenp = Sten ( pat 25 - 7 while Ci< am £8 f |] D Fst . N16l¢j[o}a |Bye mg u Tetete] 41 Sevit A genet Alel= peal [OlaLsleo]A SOLE |] wlBleloja ]B(D. - Pixin e Quast + Implarwt dhe ppeultons oj the Que as Qusut by ere “ e tnt Chi td. . Ota Apply the Same on. fob. Scheduling matinee Vee dota strtuttwu whch works on te princple FIFO element tot pusent tie the longest time will get oleted (ost. _ Sodio Trto Wu muse tokes pace ak the sua pees ce Hem HF 9 Bote) 3 Noid inser sem 4 — ) intitem 5 | Maa _Puirlt. Cg Ouanqlow _tutuxn Pri ( enteon the iHern: in!) — anh (led) Bim oleenj: fem + 4. void datas went CD & te05 5 Cp) Pring ("@ ivempty'); wehwen 3 put} (* Chmentiubted : “a to glee) s ks ok display ¢2 ris anti ip (Fed Praintt ("ais trnphy") 5 pnt] (" contents ef otwur au stn"), fon Liz t igen i++) 7 paint {7.4 \n" 40D), _ isd maint) vere: ——L_|__ roae piu (fe Pier ye choite \n" 5, Sok [td 19 - - Susitth (ch) pees < Case tt Instetion C5 Com? dulitisn C9; oe a IS) Grae the disadvantage ©) the ondinaxe, Que 4 Ths _ Solucl in ciyeulat quius - Explain witha cuifable Cixample _0| how you would implinunt a. chuden @usut euing : Clinanico! lly a Mocatecl Ova. Ay DiSduantage © 7 Is]ss]us]3s]2% 7 isT LT [al 5 = - i Huu ingoctim iS not Hl / - __, Peasible eutn Hy - des HEU MOL | _snough imply Spacs a he sotion is noe oda auaf lbh Porsible aun tga enbire [ OTF empty - => DE custom fe doassbaet of og ze tt, In Cettion snotpossible : ¢ Fnsent the date Pn chr uot ashion © + mimore Wed optimally » re mee. Tnwitiomn te HS Oe ce Lap Aalition 4i2 value eo = is ——e | Corcudowe Quest wind Cy annie Ariat oe | “iat sizes fat gs feo se 1, tounit 205 Anwwit_L9 uo" =i “wing ¥ yilloc > i Reo encd emu’ ge a — _ 7 ee po — _ Te Cesant t= gsize CO —— > —_—_——_— Prot Cg Full Creu Si3¢ dy 1") 5 Qsze++ 5 = Cint+D euatloe Csize SiseqCint))5 ge head if (foe & fon(tosize -25 tSe BL —) a qtien= qu ‘5 J _ ttt: a n= CONT gsize | oar alu =item 5 — | count ++ 5, So - T pebte 0 and displons y Same a» 09+ Ie.) How Stacks au seeprenen ted using, Couto e Hinclucs < Stdio.h> _ - tH dating Size Ss - | Hdefine Size. : oe Sint’ s[sizt ) » top == ow a = Void Push 95 Noid Pop (95 _ Void dispploy (95 int mato ty" 1 Push .2- Pop. 2-Display .4.xyxitin') > a | “Paint ("Enter jot choice: 10"), Le eh pd yeh ds [ suiileh (ch) & _ Casey Push oo, break: _ Can 2: Popcds breaale: 7 1 diplay 5 breale; _ canes a Bxitle) 5 break 5 Clojault; i paint C" Tavalidl We _Prataty 0 Stack K ounjloator)s - - — tetuxn; a yy a — - Print Co Enter an item KOOL d Rim Dy a Sle+top}= ikem - ~ Pe — TY vpicl Pore 9 « — i Cop=--) = | L om __ Padoll( " Gtack tandoy low\o")s eters — - preint C* Sak is Eerptyudea| tous"), sultecn 4 ' 13. guint} CS contents o| the Shack aes tn") don(iztop ‘s ipzcot--) purt} (ed ot, sfiJ)s Aaume 821,829.63. Evludhi the following. (@)-a-fB+c- BA tef— b- fec+t CaA-+* | “| ABAC-BAtC4~ : fet B=2 C-3 1243-214+3¢ - 3+3-24+34- | beg — 4434 = 44. be Ake, +* CBA~1* 1234%* 321-4 | 1G 301-44 | 5 321-+* | S314 ___ 14 Apply suitable data Strulune fo cout ingiy to porkytiy | Ad etc- BtE | FICG +H). Wet. 0.6 furcht 5M 40 Conunct infiv to prslyiv Oypirenion |__Wold _pexttix (void) 2 chon Symbols —_prececten te token + —Cloten == opetand ) —_poutnt} ("lec "Sey mbot 5, thei} Ctoken == 94 porsun )) x hit Cstack top) 1= Lpaun’) paint token Cpop 0995, ___ Fare 3, while Cisp [stack Crop'J> = 7 & Ctoken’)’) Prune foken Cop 09 )5 Push Cloken):, J _tehile Loken = pep (594. Eee | painttoken Ctokend; —— : TOS oS ——____ ot built @ Clundlton 4o quali aman - ss ec] rotund Covi) ME Oy - x ee a aa rerclence token | that Symbal fab opl » op2 5 alien int neo + - 3 a int top=-15 - “token = gettoken 7 5 | ro Chee, CE symbel gnds t- _ Ty Ctoken =~ operand i wh ( Symbol-'o'D» | rl om t Z 1 Opa = popc> 5 Op = Popt?s — Switch Ctokend a AO : - =| Core Plu»? Push (opetop2), break: = Pwh Copt~op2)s briak *_push Copt #0P2) 5 brutes —_| Case mod + push (opt fo op). J T Ren egettoten (Asymboliends ateturin POPC? | pert: noey Sean stack ——— 8 p se 6 ge : = oo - pas. - ~ eo RESC ys ‘pesct zs - —— _ —RecdCHD a FD = + PBC$C*D-E / +7 ABcSC*D-E = 27 Pec $C eD-EF 7; 37 Ree $ Ce p-EF/ C /C Bo $CND-EF/ Cy tie Age $ CHD- EF IG = =1C+ PBe$ CHPrEE |G a ae Seed cD EF /GH 5 7C2) PES C*p-E FIG PECs CH DEFIGHT f. b- A-S/CC *DSE)- a a A a ae AB AS ABC ABE —_ . BCD) J yey RecoedE own, |} mae _ & (CA +C84eD)* 0) g CetF) | Token Stack olp c |) - | > | D oe 4 - _4 t et ABC -D* & *€2EC Bect-0T + 4 )§Ct fect -DE ee eae «Mer HScq-vt F Aec+-DE FAHY ad.) Ca tb)tcld _ _Tokn take —_ONP ¢ c é _ o C ou _* Ct a bb C* ab =) Cum [+ + ab + lo¢@ + abte —_ if a a AL bch I abtcd /+.- L € (Clazb)-c)+(d ¥e))~ prc. L I Token Sauk C tC Ul _ bo _ Lf a Lo T _ |b I — IL x — 5 - + ( - a _ | % @ —_ 3 = tC -¢ able-det} Lt a ~-C abi c-det-+ta a | oF =-Ce ab] o~-detta 7 e -c+ able~detrae oo be de Hace jo ab |e-du¥4qc%—

You might also like