Download as pdf
Download as pdf
You are on page 1of 103
INDEX PAGE Si. 2o 20 Mo Be 6. to No. Date u|njoo w]ul 22 18 |ujoo a5 |ufoo 22} 29 ol rr] 22 3] 1229. NAME OF THE EXPERIMENT Singly litpked list 1 Creation 2 Pnseion 20 Delten 4 Toavessos 55 Merge two stogly linked list Dowlaly linked bist 1e Creatron 22 Ensextton 3. Deleton gq. Fraversol Stack operatrons using hevag, linked ist Infry to postfix PostPie expression Reeursryn Enix prebix Linea, Queue using amnerg Lincaw Queue using Unked buck Circulow Quuw lo Ineutron 2. dion 3, Seasch and out: Page No, 1 4-14 [p-é (4-21 22-23 J2U-2F 24-20 Marks | Grade ‘Assigned | oe Were We pote 23) ie Scanned with CamScanner 5) INDEX PAGE na Date NAME OF THE EXPERIMENT Page No. Seah Roa &.| aolinla> | Chooular deque 31-34 a. | orJotln2, | Lipplement Binary bree | 35-ul and AVL Tree o:| o6loio3 | Graph Fravessals 43-43 * BFS ¥ DFS We] 96] 1]98 Lintar ecarch 44 Binasy search | s0o1f3 | Bubble covt method 45-46 Selection sort methool ,.olees Magesovt method s1-4¢ Quick soxt methed , Hashin, I | s3Jo1 log ng rata Kp paboan teaaching algonllhm. Scanned with CamScanner Name of the Experiment: ___ Date: ____ Page No: |. Wrike a C progaarn that uses functions to perform the following opevatmns on single linked Uist. }) Ceeattor W Insexbwn ii) Deletton Ww) Feavessat vp merge two single linked list. # include shouctnode 4 | _ink lata; _ struct node *staxk> NULL ; | _sbruct node * fixst> NDLL 5 _ —vOid eveablish ic) fe oe __Sbruct node * newonode ples int ps __ - — _ printf (+ Entes ihe element tobe inser bed In" ys scanf (hd, un); apapanenice newnode = Cree") malloc (sixe of (struct noc )) dewnode > =n; iP (ston » NOLL) i hewnods - nexb= NULL + Slast = newnode s y ele JBIET Scanned with CamScanner ply stat: while (pla next] = NULL) i phy: ply next; j pty next = newnode ; Pevonode — next = NULL + 5 5 vold fnsex b_ beg) i stouct node * newnode , ¥ ptr; intn ; pntt (* Entes the element that has to be inserted! at beg \n') scant ("d's &¥p); newnode - (structnode*) malloc Csize of Cstauct node Ys ply-start ; 5 oh. newnode > data=n; hewnods — next = start ; staxt = newnode j vofdl insert -end ¢) { struct node * newnode »* pty; Scanned with CamScanner Name ofthe Experiment: Date: Page No:_2 fot ns pootf (‘Enter the element that has to be insexted at end\n") ; scanf (°Fod', kn)» newnode = (sbouct nods 4) malloc (size of (struct necde)) prs start; newnode—dala= n> |_while (pty next J > NULL) |__ptv>pexk= newnedes |_Newnode~> newk= NOLL} tj fp | void fosexk aftr t ac Stmuctnods *hewnode£p ip ee fntn, nur 3 prntf ("Enter a node afta which the sloment has to be inserted |n"); scant (*%ol*, ’num)s puinlF (“Epler the element that has tobe Inserted n") 5 scant ("ody wn)s newnode > (stauctnods*) malloc (sixe of (struct node)) Newnode > dataena pve stovt; JBIET Scanned with CamScanner Peephy: pho: whik (preptr> datal > num) psepte- ply; ply= pbss next; psepty > next -newnods 7 newnode > next> ptr 5 voll fnsext — before C) f stouctnode *newnode, *pts, ¥ preptr; Trt, hum 3 punt? (' Enter the element that has to be insevteal In") 5 Scanf ("al ', un); newnode = (shructnode® malloc CeiceoP(structnode)); newnock — datu =n ; vo ptr= staat eh sa prepte= ptr; while Cpkv data] = num) i prepty- phe pire ptr nexe: whilet fj prepte nexb> newnode 5 newnock 2 nerks pbyr; 5 Scanned with CamScanner Name of the Experiment: Date: Page No: _3 vofd. deleb—begC J i . stouct node * ply: if (stayt == NULL) paintf (‘uncles Plow \n"): else pt — |___phrs staves |__start= staxt> newk }— printf (* the beg elernent cleleted +); * — | —_Precphy je : po Pi | void delete end C)_ - te — NE __stuct_no pbx, Eproptes das nest is SP Cslowb: = NULL) a printh(* underflow \n" )z cle { ; 1 ptv=_stast ; —_preplas ptr; while (ptr newt] > NULL) i JBIET Scanned with CamScanner a | Peph ple: ply pla next> j P¥eply > nexl> NULL; - Punt f (Ihe end element deleted’) 5 fee cpla); j j vold deletuaftw ¢) { struct noodle *pto, * preply . temps int num ; printf (‘Enter thenode afta whieh we have to delete the rode\n’), scant (° %ed°, Ynum); iP (stand == NULL)» paintf (“ undeoPlow \n") 5 alse 1 ‘ t wa ply: slavt ; preply = pir: while (preply— data} = num) i prepby= phew; ply. plo next ; j temp: piv; Scanned with CamScanner Name of the Experiment: Date Page No: _4 prepty newt = pty next- pointt (“The element delted."); Free Lternp) 5 j $ —vofd display 4.(). 1 |___stauckt node = |_printf (‘el net t-Law\n') 5 | _whil Cpbr> next} = NULL) i _ . _ | paint ("l%edI%uj “, phos data, ptr newk)3 | _ptrs plo nexbs printf Ated |. dul “phn data, pls next). Void counl_nodes L) _ 4 oe Slouch node * phe j fot C205 pies Stawt 5 while (ple! 2 NULL) 4 Scanned with CamScanner Name of the Experiment: Date: Page No: _6. Bp Meri ns Nyt ples plrsnevby Be Ge - __paiet (“nos of nodes. in linked. a.teb on ave -e tad\ 9C)3 j | _void cxeatilis 20.) ed shnctnods*) read ne renee P51 rag ie Sscank(*%ed 5 bn) |__newnode = (shouchnode®) ‘malloc (sizeof (shavetnode )) 5 | if (fioske2 NULL) = fe oe Tae! abd heeby “yt |__newnode> next 2 WLLy else Paes el, __ pire fist; | __ while (pts next = NULL) fe 2. ‘IBIET Scanned with CamScanner EE j PHY nex!» newnode : Nevonode + nexbs NULL J J j void displauy, ¢ y i Strucl node * pts 5 Ply = fice; printf (“elements of linked list-2ave\n"): while ( ptr—snext] = NULL) { Printl ( "Iod) ful >’, phe» data, pbr> nent) 5 ply- pts > next) j print fF (“led eul\n", phedata, ptr-snexk) ; j vofd meagelist oO 1 q ~~ stmecl node ¥ pho. *newply; phr= stact; while Cptv—> next] > NULL) [ pbs: plo? next; j Scanned with CamScanner Name of the Experiment: ate: PageNo:__ pv >nexts_firstz oe 4 hewptvz stavt : - puintf (“elements of list ales mewging axe\n"); while Cnewptr next | > NOLL) { |_ printf (“ed) ~ul>", Newpls data , newpls > next); |_Newpls= newpla next; - |_parott (* “ed Mt Ul", newplr data roe next); } vo'd maint) ee — | ptott poee ee yeni) | pent (3. ThserKatend\e)s is ~ Drsert afte Ws pl — paint ("5. Pnsert before \n")3_ Pe printf (6. deter hea \n")5 paintf (“7. delet. end:\n"); paint (“8. cele after \n") ; printf C4. dfsplay \n")5 |___paintP(“lo, count nodss \n") ; point (“IL Create 2\n"): s IBIET Scanned with CamScanner Pantf ("yp display aw) printf (3. Merge Lyo\n)s I point f (*12,eatt\n')i 40 i ¥. print (“erste the chole\n D7 scanf (“%d*, & hd’ Switch (ch) i case ts create lish 1005 breaks Caer § insext— beq Os break; case3 > insext- end); break; Case: insert afta 02) break) cores: insert. before): break; Coe 6S dela leq QO: break» cose? deldte_endcy; break) cose 6s debi after (); break; Care 4 ; dfsplay 4003 break ; Scanned with CamScanner Date: Page No: 1 Name of the Experiment: —Caseloz_count_nodes LI; breaks Cell 3. CreafelibE2C) 5 break; case!) ¢ display 20); breaks Cas 13, t_meage. Ws. Cy break j_ eds tt | default + printf (enter correct choiteln’); extk(o)s _ a — 5. _ - a h. he ai —__while(ebézia)o gétth C1, , _ eG ip tt Outputs ap. eu _ Pater gue —— Enter elemenk to. be,thsexted.tho, Ente the cholw.. 1 - ___Enies the element to be inserted +20 __Entes the choiee + | __Enterthe element fo be insesled 130 | Entes the cholw +4 Elements of linked hiss are, JBIET Scanned with CamScanner ES 1020-30 ¥ Epler your chotce +2 Enkex ihe elemenl kp belnserted bg *° Enter the choi = 4 Elements of linked list are 5 10 20> 30 Entew the choite 33 Eptea Ihe node aftes whi ich the element has to be Inserted al end-t ye Entew the chol@ #4 Elements of linked Vist - Lave. 5510 202 307 45 Enter the chotue + + Enter the node afte, whtch the element has to be insexted 3 20 Enter the element to be insevted ? 25 En tex the chofee + 4 5 W207 257 30- Enter the chow + 5 Enter a node before which the element has bo he frsevted s 30 Entew the chote +4 5 10 720-7 25 30 —2 45 Entes the choi +6 The beq element deleted Entev the chofce + 7- —_™ Scanned with CamScanner Name of the Experiment: Date: Page No:_& The end clement deleted. Entex the choia 28 _ Entex the node after which we have tv delete the node $25 The element deletid Enterthe choice +4 __ Elements of linkeel list-4 axe —lb20>30 —Enter the choles io ——ho-of nodus_in linked listare 4 —Entex the choice 2 !@ a —Lntexthe elementiobeinsested 22 —Enterthecementiobeincerteds33 — Enter the element to be Incexted 2 44 — Enter the choice $19. a J Peve of Sista ——_— =e 12-533 — 44 Elements of list afte merging dre — lO— 20 230—7 29 —> 33 JBIET Scanned with CamScanner Name of the Experiment: Date: Page No:_1. 2. White a © progsam that uses functtons to perform the following operations.on doubly linked ist » I) Cveatwn — £) Pnserxtwn &) Neletwn iW) Traversat, H inclucle 2 stdio-n> duct node i _ Stoucknoole © prey - __ | tnkdetay —— —_ |shnect node *pecki ee a anna Shructnode* stoxk= NULL: a |__vofd eeatelisEC). pf sy |_Staurct node + newnoole., phar; ink printf (“enter the. element to be inséxted i); scant (“hd’, MD) Newnvde =. (steuctnodle® malloc: Crizeof (struct pect. y: Newhock—> data s = - iF Cstavt-e2 NOLL) t Newnocd — newt > NULL; Newhode— prey > NULL; Staxb > neeonode} — JBIET Scanned with CamScanner else t ply= start; while (ply> next} = NULL) { pty= plo next: j ply next = nevonode; hewonods— prev = ply; newnode — next> NULL; j j votd fnsevt —teq Cd ? struct nocle *newnode, Fpkv; mre ener the element that has bo be Inserted at beq\n"); scant (“ted", xn); newnode> (structnode *) malloc (aixe of(struct node); phr- start) newnode > data>ny newnoce next> stort} newnocds— prev= NULL } tart prev > newnodes shat = newnode ; j Scanned with CamScanner Name of the Experiment: Date: i Page No: _0. _vofd insext—end¢ ) { slructnocle * newnode , ¥ ply inin printf Center the element thet has to inseated ab encl\n"); Sscanf ("4d 4&0); _ newnocle = Cstructnode*) malloc Ctixeof Cebnuctnocle)) ; __phre shorty oe | n@wnode—> datasnj; | while Cpbe next}= MbLL) ie ol pe eat —_phre pkvo nevks jo ee |__ ptt nexk > newnode; | _hevonode ~ prev pr Newnode>nevt= NULL) ae de void recta ne _# - a —_ Shruchnode * neunode,* ptr,” prephy; —Inkn, num; printf (“enter anode afte which the. eemenb has to be inserted In); scanf ("ed ', & num) 5 ‘ printf (“enter the element that has to inserted \n%) ; —scanf (“ted kh); JBIET Scanned with CamScanner EE e————$_—_ Newonode > (shuetnodst) malloe Cee of (Stet PAM) hewnode — data=n; ply saw ; pveply= phy; While (preptr> data = num) it bseply= plo; ply> pty next; j peeply - next » Neonode; newnode— prev = prepkr; Newnode > next> pk ; piv prev= newnode; j vold insext_hefore L) i gteuctnode *nevonode » *pbr, *pveplr; Ink ,num > a pant? (“ens a node before which th clement howto be inseabed\.s ” A Rak scank (“ed ", un} * paint (" Wter the dement that has lo insevted \n"); scan ("ed") un); newnods « (skruchnods #) malloc (ike oF Chuck node)) ; newhod~ data h; Scanned with CamScanner Name of the Experiment: r : bate w Page No pkv= stasti _ __ prephy = phx; _ | while Cply= deta) = num) | prepryonext= newneck ; newnode newb = phx; Newnocls > prev = prepbe; phy — prev = neonode; | eof ol cle bebe tse) 4 a _ shuct noc. *pkx; __ ff Cshoat-=2 NDLL) ___ printf (“under oto Ih“). else oie = _ phe stowk 7 stavk = stavk— next; __ Stosta prev: NULL; paint (“the. beg element delebid") 5.1... frec(plr) ;—— ; ty - JBIET Scanned with CamScanner it 4 votd deltu—end () t Struct node 4 pk: *prepty } ff Cstarb=» NULL) printf (‘underflow ln"); else é plr- start; prepty- ptr; while-( plo > next! = NULL) i prephre pto; phys pbs next, 5 prepkyr next> NULL; printf (“the Bnd erent detezd "); pree (ptr); 4 j : A void dela — afta C2 wa i struttnode * ple, * prope: ink pum; pantt( "enter thenodeaftu which we havety clelde thenade\n"); scant(’ a ypu); if (staok 2 NULL) pantt (Sunder flow \r")j ~ Scanned with CamScanner Name of the Experiment: Date: Page No:_W se. ee ee ee ie oe — Phare stasis _ peepbrs pk while (preply > data) > Nom) EEE _—prephra ply; 1 —phr=phes neve - Beg —Pprephrsnevt= pheonexbs pix next— prev= _prepbr; a | —Punth (“thedementdeletd ); free (pb): — : __| j _ _ — Be = vot cleletibePore () —EEe Sie _ shud node —_inthum; — eee -printf (“enter the hoo afta which. Wve have to delete the node \n’); scant (%%0l", Anum): —If.Cstoah= = NULL) printf (“underfiov \nt) cue JBIET Scanned with CamScanner t i ee ee ‘phere Skant ; Prep. ptr; Whfle, Cpiy-5 data» num) t prep: ply; pty pty Next) 3 Preptys prev next= ptr; plys Preys preptr— prev; Pant (*thedement deletad '); pree (preptr); J i vod displayforward ¢) i sbuct ndde * phy; pk - start; PODEF (* elements of. linked ick-4. axe \n") ; while (pty) » NULL) ih i Ai ponth ("Mul Yd | % ul a> plr-sprey, bbs 4 7 a Pkv= pho next; 5 j votdl display backwasd (). PB next); Scanned with CamScanner Name of the Experiment: Date: Page No:_B iy ine gee 3 a Gh si tf Shrueknode* pla, “ |_pbr= sharks _ pontt (“elemenk of Jinkecllitt-4 are \n') whik (phy newts > NOLL) LC |_pirspleonevbs ] |_While (phe) = nolL). — i a | pint (Ynulyed itu le-> § pla» prev, plrdata.phronert); | place phos prey, 5 j _— — | Votdmasmity sob iy ed jok Ch z. ie a __clesert);_ | printf (Y4tréabny, a —panif.(%o. nsertatbad nt); 1p =stl 3h |__printf(*3-Pntevt at tnd \n'); |__ print (“U- Insextafta \n'\); | printf ("5- Tnsext before Wnt), |_prioth(“6- delut beg Wnt); —| LL i JBIET Scanned with CamScanner CC ————— pant (7 dette end \w )/ Poot (“s. delae afte \n")/ Pantt (9. delete before \n') ol display forwasd \n'); Pani ("Ils display backwasd \n'); do t pont? (“ent the choice \P)/ ScanF(* %d", ecb); switch (ch) i Case 4: Create StC), break; Case 2: Mngert_beg Cy; break; cased + Insert_end()7 break: case 4: insext- after C7 break ; Cause 5: insert_before(): break Cases deluh—beg 6) break; Sf, case 1% delete-endey! — break; : conc g s delete aftucy: break; coreg: elu befovec), byzak: Scanned with CamScanner amet the expeiment cae: Pare __cascips-display for woad.C2- - _ break; Casci: display backward () break 5 defaull : printf ("enter correct choite \n’); —exitto) 3 | Enter your cholu it Elemento be insesbed to _ Enter the element to be-insexbed? 20 Enter the el ement_to bd insested + 30 _ Enter the choi : 2 Entex the element. that has to be inserted at beg: S | Entex the chow :3 Eprex a element Ifat has to be inserted at end +40 Entes fhe choie: 4 Enter a node aftr which Ihe elemenls hax 10 he jngexted +20 | Enter the element that hor to inserted +25 oe JBIET ———— Scanned with CamScanner / Epler the ohvive: 5 Enter a choiwe before which the clement hat Ip bec inseed.s 40 Entex the element tial has 1? be inserted #35 Enter yours choice +6 he eq elemen! ole tele Entex your choi 7 The end element celetd Enter your choi +6 Boter the node afta which Wwe hare Jodelete tenode +40 Bnlex your cholte : 4 Bnla the node afta which we have to cele te node +20 Tue element clellzc Enter thu choice +10 Elements of linked Uist-4 ase lo— 10 26 20 rs , < % Entes the choice : I) oy ee K yee 30 85-790 4o Scanned with CamScanner Name of the Experiment: Date: Page No: 65 3, Waite a C program. that Implement stack oper cebrons. wsing L) Aeawaugs- | #inclucle < stdio-h> 4 inclucle< sidifb-h> 4 define SIZE yoo __Int stack [SIZE]: Inf tops=47 | _Yotcl push C2. — a) inte; = = oe |) P Clope= Sizp-4) | paint (“Stack Overflow\n4), ee fo - on 4o-beenfeved.:"); — fF (%4ed', bey lop-Hts stack [topJ=e: = y at Yoid popC) L if Ctop-=-4) : _ point (" Stack undesPlow\h’); a JBIET Scanned with CamScanner ete « gtack ClOPI)s stack Trop]> NULL? top-- j j void peckt) ; if Ctop=>-4) . point? c“ stack empty \P ‘)s Us sna’, stack fopl)} Print F("peck elements * nal stack 117P 5 votd display C) int ty if Clop>>-1) printf (Stack empty \"); ae, tant? (“elements of stack axe\n") fow Ui> tops f>=0; f--) printf ("4ed\n*, stack O1]); j J void main C) i Scanned with CamScanner Name of the Experiment: Date: Page No: _16 int ch; clusea (2s do i printf ("\b 4. Push \n'); __printf(“ 9. Pop\n?): paint ("4 Display Vi) > | ___ paint (* Entex your chotee: nea pops Cane] peck (Js. breat+ = case 4. displouy tl) bueak; default : j 5 | printf (°3, Peck Int). Case ts push) je 0 breaks breaks |_____scanf-(*%ds @chye | cw Cech) While Cehz=4);_ cheek geich cy printf C" Pnvatid choice, please hy again \n'); exttCo): JBIET Scanned with CamScanner BR). LINKED LIST H include 2 shelto-h> # include 2conto: h> struck node Int data; struck nods * next; iB sluctnode *top/ void push C) t int val; shacct node * ply; pir= (sbeuctnoc*) malloc (sizeof (stnietno de): paint t (‘enter the Value"); i } scant" %d",, val); 4 if Ctop == NULL) A v piss data: vol: phy next> NULL; top pkr; J else f pty data> vol; ply next> top; j Scanned with CamScanner Name of the Experiment: Date: Page No: _V7. _puintf (item. pus hed’); 7 j__# Void pop lL). i Int item ; __shructnode * ptr; Tf Clop== NULL) i a a | Printf (“underflow jy elgu_____ — a _ os Jf =| |_____ phys top Po _ | __ top: fop>.nenbi Free (pty | ___ print f_(* item _poppedl"): o pba yt J tee j - void display CD Ef. int ip shock node. * ptr; pte= top; __if Cpt == NULL) 1 Scanned with CamScanner puif (“stackis empty Wn")? j alge t rant (“painting clack elements \n")/ whit plo} > NULL) i printf (‘aed \n’, ply data), pls - piv next 7 j j j void main ) i Inteh 5 clysex£)> do printf (“\n\n chose one favm the below Options....\n*); point? (° \n4. push \no.pop \n 3. tisplay \n 4s extk’); Pant ("\n enter your chore \n"); scanf ("%d', Reh)s “ gunttch (chy i Caw 1° pushed; "break; Case 2: poplds bveak ; Scanned with CamScanner Name ofthe Experiment Date: Page No: 1G casc3_ altsploy Oo __ beeak; default: prinff ("please enter valid choice") exitCo): j i while Cebé23)2 — | _____gefeboy, ____} oe Oubpubs | Cheose_one from thu belowophin |. Path | 2. pop be. disp 4 Get Entex your choig: | — Entes the volur‘10 a _ jem pusheel _Eptes your choile + | Enter the value 129 iter pushed Ente your cbote-s | Enter the-volue + 30 JBIET Scanned with CamScanner —=—==—-_~S—i‘<‘<; ;]}}BHhkfe em pushed Enter {your choice :3 Printing tlack elements 30 20 lo Entew your chote 12 item popped Enter Your choices. item popped Entey your choles > item poppce Enter your chor ce 2 underflow Choote one Favm below option 4. Push 4 yn // Aer 2. Pop a ww 3. display 4. eth -Entew yous choiw 13 Staucis empty. Scanned with CamScanner Name of the Experiment: Date: Page No: 14 4DWnite aC program to convert infix expression to_ postfix expresovn using stack. / # Oncluck chav stack boy; ind lop: -4; __vofd_ push Cchax x) - 1 pL ef — | __ slack [4+tlopJ-x- —— _ es ee |__chax poptj) a a REiGipps 2) eee nee Aad gy i 7 _ = if (xz=() | return 07 | P(x ee el x oe") wefurn 1; . | J im) ie Cxestw I xe='7) a. 4 | wetuan 2; — ta gt JBIET Scanned with CamScanner 4 vofd main c) t \ \ chaxy exp [20], pos [20] cha ¥e,Xx3 int f> 05 clysex C22 printf (‘enter the expressivn’): Scanf (“s*, exp) @= exp; whfle( Fe} ‘\o’) i if (isalnumC*e)) pos [f++]= *e; else fF CFe=="(Y} push Ce) YL else ff (*e=2°)’) sé i while (x= poply) b> °C") pos [i+t]= x2 j ake i while Craiooity Cstack Clop7) push C¥e) J ett: j >= Prlonity Ce) pos fi-+4J= pope); Scanned with CamScanner Name of the Experiment: Date: Page No: 20 while (top! = -4) pos Ci++J= popt) pos [?J=“\o's paintf(“\n postfix expression ‘bs ' pos) + qetehor: a | Oukpubs |_Entex the expos |__ (Caxb)jo)+(elf) _ |___postfi expressimao_ pie Noel JBIET Scanned with CamScanner == ———=——— ~ aX EXPresstD, ) Waite C proguam to evaluoty postfix OxP n # Include cctdio-h> # Include < conio-h> Int stack fro): int top: -4: votd push Cint x) t stack [+4 bop]: x! j int popc) i return stack [tops j yvold mainc) i a char exp boy SL chas *e) Inf 412,03, hums elsscrcy! pant (“enter the expression tty scant (“%8", exp) @ = exps while (%e! > ‘\o')* L if Cis digit (*e) t hum: ®e-4e" Scanned with CamScanner ‘Name of the Experiment: Date: Page No: 4 push (num); j ese t n4= popt): no= popor switth(*e) a |) tate pgs nde breaks NBend2-ntp breaks j cone ns t n3eni*nos breaks j Coacs/"* IBIET Scanned with CamScanner NB~ noyng 2 break: j 1 pusb(n3): j or j printf (“Vn the vesull of expressi0 e getth Cy j Output 3 Enter the expression : 934 Ferul-) 7 Result 24 hear ¢ Tt fact Cink) + Ink main () t inf numval; Date: Page No: 22 | ____paintf ("enter the number”), | scan (°%d', ’num); oe | val: factCnum); a - | ____fnt fackCinen) 1lln==0) oe set tj ae Cn*fact(n=I))) _ gett.) hi _ I Output ¢ _ Enter the numby 5 factortal of 5 >no JBIET Scanned with CamScanner q Watbe a C pw Wing stack, . # Indudezstdio-hs char stack C20]; inl lop: -4; Vofd push Cchasx) { stack [44 top]= x; j choxpopt) TF Ltop==-4) welurn-4; else vetum stack (top--J/ J int palovity Cchaa 2) a Lig Cee 2‘) Ls seturn 0; 4 FP Cxsete Il Hoe vetum 1; Gh Cxesta ll x27’) vet 2} 4 vofd maint ) chow expl20] pos foo); chas Fes Scanned with CamScanner fo convest infix exprestion to prefir exp, ON “tty Name of the Experiment: i Date: Page No: 23) i Inb¥ fey yy —clwsew 3 = : — {_« —— print (“enter the expression’) —-scank (“%5", exp); _ 0: Shrvev Cexp)) ———Whik_CFefa‘\o pos [ittJ=*e5 else _ a fe (¥e=2"() push (#2); _ - elge fE-C#e=z")’) i - — ——while CC0zpopotet) pos fit+]= Xi a = 4 Pail be a - a a —— while. Gpriowity. (stack top) 22 purity (#2)) pos [itt]+ pop (2 push lfeyp ett — woe fs a - while Ctop}e=4). a ee pos[T++J=pop(a;. HO ——posfiJe Nop —— JBIET Scanned with CamScanner PowBEPC\n pretty expressron eS 4 SHTEV al qeich>: j Output Enter lhe expresso ab be+del fg- e Prefix expreseor + abe-[defg * Scanned with CamScanner Name of the Experiment: Date: Page No: _24 6.) _Waitea C Progsam to Implement Ifneas quer using 1). Aevoys. # inclade < stdio-h> # include ¢ stdlfbsh > 4 define SIZE_100 nt quer Csre];- een fonte cag i |____vofdfnserfc) —__ fst | eee fhte; \ ff Cveowz 2 “17E=1) ee el 7 |__priptf(“queweoverflowr); 9 bintf (ener the elements); —Seant(" tod" ke); TP (Poont=>-4 we vean: _foont= wears 03. dee - = : veats vear+1j Jack quiuctrear) =e; - fe 7 10% _void debt C) taf tylet JBIET - Scanned with CamScanner 5 v tnt Vol ; f Cfront=>-4 |] Front > rea) FeotE (element doluted ts reds vol) Front. Front417 j j void aisplay uO “tnt ts if ( Front: 1 II Front > 100 ) Print f (“queue is empty"): else U peintt(“elernents in the quiuse ore); fox (i> Front; Teveon: f44) Panit ("4d In”, queucety): j 5 votd Inaint ) : U Int chs clssert)yy do i pantf(’\n 4. insert \n'); pont (2. debt \n*); pantf ('2, display \n"); Scanned with CamScanner Name of the Experiment: Date: Page No: 25 —-paintf.("enker your chote'); a ‘ —Scank("%d%, keh)! Swilch (ch) 1 case 1s Insexi Cy breaks | __Case 2+ delete (1 0043 ¢_ display Co? break: | __defoults_printf-("involfd choice, please toy again \n')s | exit Co); 1. Insert 2. Delete | 3 Preplay- Enter your choiu +) ___ Entes the element +o JBIET Scanned with CamScanner OO Entes your choiu =) Entes the element ¢20 Entey your choice +3 Etmenb m te qui ase lo]n , 20], 30]n, Yo] Enter your choi: Element delkkd is 20 Enter the choite: 3 Quire ts empty a Scanned with CamScanner Name of the Experiment: Date: Page No: 26 TT) Linked Mets. — = - _ 4 include ¢ ctdto-h> _# Include ¢conio-b> Structnode t Int data + Shouct-node * next; ja st |___sbructnode * rear. NULLS __! | ___shructhnode.* flfronk= NOLL; void InsexEC) ptr-_Cstructnode.*) malloc (sizeof (sheuctnode)) > printf (“enter the value”); __scanf(“%d", eval); 1, ptrodata =vol) nwa iF (feont==NDLL) i Pronk: wears pbos i Teas» nexb 2 NULL; j ! else JBIET Scanned with CamScanner COE LL t Year next= pts ply next> NULL: i vear= pty; j y I printf (“sd element tnseated spor? dala? i] vofd deft) | © ink tem shuct node * pts; iP Cfeont == NULL) printf (“underflow ne else t ptv= Poont ; front > Peonk > nexts i] Frec(pho): t | j ‘ ly | paint (" itero deleted *): 4 | j vofd display oO) t ink fe skmuctnode * pea’ ples Paont; \ Ff CPavnt == NULL) prin FC queues empl") else L __— Scanned with CamScanner Name ofthe Experiment: ate: age No: 27 t r - _ pani (“printing queue ¢lements \n"): while(pty Next | = NULL) i printf (“td ", ply> data): pbx = plo next; | _ print fC" al”, pla data)s fnteh _ : - rant£Yn\n choscone from the below opton\n“): printf (“\n 4-insest \n2, dekte\n3, display \n 4. exft) printf (“\n enter your chotue Wn"); scanf(“%ed‘, kch); swilch Cch)» i Cone 1: inseyhC); boeak; Scanned with CamScanner i break) Cone 3 5 display cys i break» / Core ys 43 dteplay printf (*extsting’); Hl ek i| defaults if 1 t | Punt fC" Please untervalid choice’); j | | J J While Cohe > 4); getency, J. Output ¢ I. Insert 2. Dele 3. Display factoids gq. Exit if paler , : > as Entes your choi w; } ( . ia i Enter the value: to } Enter yout choiw:) Ente the value ;90 Ent the volur : 30 Scanned with CamScanner Name of the Experiment: Date: Page No: 22° a Entertie cholw.:2. _ - Tiere dektid | Enter the choice 22 flem delited Enter the choice 2 2 ___ttem deleted a | Ente the choi 23. ee | Ou ts_empaky ee |___En tex yous choite:2 __ Quem _undabbow =< : JBIET Scanned with CamScanner ng operations on tin, : follow Wailea C progsann to perfor 7 and tolint Dequewe 3) gncertron ) delet H Se 4 include ¢ stdiosb> 2 Include cctal bly F define Sizé 400 WH quene (sizes Int faont> -L, Years -4; void fncevt CD { inl val; TP Cfant=20 kk vears> SIZE-4) poipth(“ queue oveaflow”) ; else i point (“enter the element"); : scant ( "ted", Rvol)s op if front 22-2 We veay-> 1) Le feonl 2 vear>0) else tf Cveaye = SIZE && Front J> 0) ear-0; alse rears weary4d, j quetu [vear)- val + pent? (‘element insested Vn"); j TT Scanned with CamScanner Name of the Experiment: Date: Page No:_ 24 Vvoiddelett) fo ink vou 3 Ff (Poon = 2 -4) i —_ printf C’quew undesflow\n')s eee BAVO eguree tapi is|os eee ee eeeee eee | printf (“elernent deleted ic fol’ vol); |_ff (Pront-=2 wear) tronk= veart3 elec if (fonts zb=t) | fons Of else a _ | Fant = front tp Jo. —vofo_dfsplay ¢) 4 — =o int TE (foont==-4 ukvear +s 74) paint (“queue is emply"); elec iP (font creas) L fot (fz twnt 5 fez veav itt) Scanned with CamScanner Prantl ("ted queue [1]) 5 j else t for C72 Front; P22 srzesf+4) pant (°Yecl, queue chs for Uso; te2 sear) f+) pref C' ved, queue (7))? fos J j vofd main c) { ‘intch + clesert) 5 do t paint? (“L.inserb \n"); paintf (*2- dette \n")- punt? (3. display \n’; printf (“enter your choi"); scan (“hd 4 uch); twilehCchy cut 4: inseykC); beeak; caster: dektC); bveap: cored + Alfsplay c; break; Scanned with CamScanner Name of the Experiment: defoulbs 6 Date: Page No: 30 paint FC“ ipvalfd chore. please hy. again\n"); exik(o) ; 4 j whfle Cch2=3);_ = —getch eye __ : oe — | Outputs _ a | de Upset 2. Delete 3 Display —_ - Entex. your cholie.:.} — Enter the dem, __ Enters He-tlement. Enter the element: Enter_your chofee 23 40520,30 0 Are Enter your choi .2 oe Element delta is 10 — Element deleted % 20,20 LE Enter your choite 13 wt Queue ts empty. JBIET Scanned with CamScanner & Writea c Pv0gsam to perform following operaluns.0n cat | Dequaun 2) Insextwn f) Deletion i) ‘Seasch and count # fnclude zctdioshs 4 include cconio-h> # define MAX + int deque [MAX]? int lefE>-4, wight = -4; void input—deque (): vofd output — deg ue C ): vold insert —leftl)> vold tnsesb— wig htC)s void fnsest— lefEC) ; void dela wight C9; Lo void delet — leftcy; void displagt y Yyotd main CI i {nt ophon + clesew0); printf ("\n #°* main menu®**** *) ; point (*\n 4. tput veataicted deque 9); pant fC In 2, Oulput seobicled deque:); paint #C* enter your option: +); scanf (*%d‘, & optrn) 5 Scanned with CamScanner Name of the Experiment: Date: Page No: 31 Switch Cophon) { Case 43 input_deque C)) break; Com 22 _outputdeque 5 — break; 7 =e qeten . } |-—Vofd inpul—deque()—* ee i a |} do _ _ _— — Paint f ("\p INPUT RESTRICTED Deaue."); — paint (*\p 4. insert ab sight"); = print h(“\p2. debit from left); printf ("\n 3. delet foom aight ls pant" \n bo display”); printf ("\n 5. quit"); pot f (“enter Your option’); — scant ("%d%, & ophyn) 5 JBIET Scanned with CamScanner ——=—=—_—_— # ~ Switch Coptton ) t Com 4: insext~ right Cy, breaks Care 25 debt do i point (“\n OUTPUT RESTRICTED beaue "); pontf (“In 4, Insert ab ght) 5 punk f ("\n 2+ Insert ob left") « paott ("\p 3- delete rv ube") 3 Scanned with CamScanner Name of the Experiment: a Date Hage tas paintF(“\n 4 splay ” paint (“\n 5. quilt); prnif (“enter Your, oplidns): Scanf (“%ed", & oplon)s switch Coplmn) fe ECO 1s |__inserb— might Cy |___inserbale pb eds |__break; |____ Cases 6 —__delcy uff; a - Case 4 - Afsplay C2; break ; 3 i while Coptron b= 6); j \ Void insert vtghhC) ft JIET Scanned with CamScanner -___ES ‘int vous Print C"\n enter the value fo be addled: Scanf (“Md &vol)! iF(ebr=:0 tedght=2 Mae 4) H (lept=s right 1) t Pink Ff ("\n overPiow"); vetarn; 5 TP Cleft 2-4) { left =or vighk= 0 j ase i = iP (afgbto= MAXx-4) = vignh=o7 - a else agbt=rvght+1 deque [right]: vol ; 3 vold ingest. lett t) i inf vol 7 paint (“\n enter the value to be acloled : »): sean ("wed ', & Vol) 7f (lebfe 20 aydight Pe MAX-4) I Clg ~>night-n) { Scanned with CamScanner Name of the Experiment: Date: Page No: _33. puntf(“\p OVERFLOW): vefuxn if (lebt=o) ee . | tePtelebe-ds +o. 3 4 Jin dequelubrT val: ==. Ee v0 FA. dtsplay C9 ——— 7 int fronke eps xease sight 8 __ ff { Front=2-4) es oe _— print (“\n QUEDE IS EMPTY); vetwrn) J printf (“\n the elements of fhe quew are: )* _if (toon 2= sear). JBIET Scanned with CamScanner 00 — t While (faont <2 vear) t printf ("éd', deque Pronty) 5 Foonk +45 j J else | te ( faon} 22 NAY-1) Fant (al deque [faonl J)’ faont +t 7 j faont= 0 while CPront 2> Tear) i printf ("%dl% deque [famntJ): fant tt; SL J j point "Wn": } Scanned with CamScanner Name of the Experiment: Outputs to Insextat aight 2. Delite fom _lebE 3 debety from might Date: Page No: 34 4. dis play Enter. your oplion ¢) - Enter your value Cfo fae cls ig) eeeensaeeenenes usenSvePOSEEEEEE Entex gour Valu 19 be aclded:90. = Entex ous vole to be added « 2 | Enter your option +2. Ihe element debefed is U Enter your optmn 5 - —The dement delefid 833 Enter yous option. The elemenk: are 22 JBIET Scanned with CamScanner rebusn fi a ° draversals 4. D Write a C program 40 fmplement pty tree # Inclact # Incluck z tonio-h > + include 2 string-h> # include stdlib-h > sincct node i Intdetta 5 I) node will stor * vight_child 2 I alght chfld struct noodle * loft child; I kt chitol 4: drecknods * search (structnode *wob, Int 2) t $f (avote = NOLL II wok data = 22) else tf (x7 wot dala) h yefuarn search (xots vight-child, 29: else seach Crook > left—child, 2)/ ean inkegur structnocle j node * find minimum (structneck * soot) te (woot? NULL) » etumn NOLL) dye PP Cxvot > left —child) = NULL) nd—tinimum (aot > lef f-child); a Scanned with CamScanner Name of the Experiment: Date: Poge to: 70. wetum sobs } bods * new—node Cinkx) { Shouck noc * p~ malloc (size of Cstructnods)) 5 p-dala> 23 _ _ p=? leHi=child= NULL; = pig Doieeesclyite|t=vNl (|! 2; Reliieseeensenesunseeneseeseeeeseeseeeeeey __reluxn_p;. 4 i __ ee i Mi tlie fet |__xedurn new node (295 |__elee fP (1-7 mwot> acto) FeeeseeNNEENENENEEESESESESESEESESEEEEEEISS rook 3 wight child > insext Cevob right child.a);. deg A Se wot-left—child = insert (woot left_ chit, 2) ;- Setusn c00t j - _ J Shouct node de Cstuctnods * wob, int 2) 4 stoucl node * lemp; {P (wool = = NOLL) setuon NOLL + JBIET Scanned with CamScanner

You might also like