0% found this document useful (0 votes)
141 views20 pages

SCH - 18CS32 Aug 2021

Uploaded by

reddy1984
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)
141 views20 pages

SCH - 18CS32 Aug 2021

Uploaded by

reddy1984
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/ 20
the remaining blank pages. ten ep, 42-48 answers, compulsorily draw diagonal cross fines 1. On completing yo Important No willbe treated as malpractice. equations 2. Any revealing oF identification, appeal to evaluator and, CBGSISCHEME 1 1 usy | | 18CS32 Third Semester B.E. Degree Examination, July/August 2021 Data Structures and Applications Time: 3 hrs. Max. Marks: 100 Note: Answer any FIVE full questions. 1a. Write the drawback of static memory allocation. Explain in detail the different functions of dynamic memory allocation. (08 Marks) b. Write a program to search for key element in an array using binary search, (07 Marks) c. Write the difference between structure and union, (05 Marks) 2 a. Write a program to sort integers in increasing order using selection sort algorithm. (06 Marks) b. Write a funetion: (i) to find out the length of the string (ji) string concatenation, without using built-in function. (08 Marks) c. Write a program to search for an element in the sparse matrix. (06 Marks) 3° a. What is stack? Write a program to implement push, pop and display operations for stacks using arrays. (08 Marks) b. Convert the following infix expression to post fix expression: @ (A+(B-C)*D)AE+F) Gi) XSYSZ-M+N+P/Q (06 Marks) ©. Write a program to evaluate the postfix expression. (06 Marks) 4 a. Explain the drawback of ordinary queue. Write a program to implement push, pop and display operations for circular queue using array, (08 Marks) b. Write a recursive program to find out the GCD of two numbers. (05 Marks) c. What is double ended queue? Write a program to implement the same with required functions. (07 Marks) 5 a. Write a program to implement queue using singly linked list. (08 Marks) b. Write a function to search for key element in a list using Singly Linked List. (06 Marks) c. Write a fuunetion to delete a node based on information field using doubly Linked List. (06 Marks) 6 a, Write a function to count the number of nodes in the List. (04 Marks) b. Write a function to perform the following using circular doubly Linked List with header node. (D_ insert_front + insert element at front end delete rear —> delete element from rear end (08 Marks) ©. Write a function to add two polynomial using Linked List. (08 Marks) 7 a. Explain the following with suitable example: (Binary tree Binary search tree ) Complete binary tree (iv) Skewed tree (08 Marks) Gi 1of2 10 Construct a tree using the given tree traversals: in-order : GDHBAEICF post-order : GHDBIEFCA Write a function to create and search for an element in binary search tree. Write a program to insert an element in to binary tree. Write a function to traverse the tree using (i) pre-order (ii) post-order in-order traversal Explain Threaded Binary Tree in detail. Explain the different functions for file operations. 18CS32 (04 Marks) (08 Marks) (08 Marks) (06 Marks) (06 Marks) (06 Marks) Write a program to sort the array elements using radix sort. Show tracing to sort the given array elements increasing order using radix sort. 52, 43, 24, 67, 78, 96, 81, 63, 27. (08 Marks) Write a function to sort the array elements in increasing order using insertion sort. (06 Marks) Write a program to print the reachable nodes of a graph from the source node using BFS method. (06 Marks) Write the adjaceney matrix and adjacency. List representation for the given graph in Fig.Q10(b). Fig.Q10(b) Explain hashing in detail seeee (06 Marks) (08 Marks) Subject Title :pataStuclad & Applications Belagavi, Karnataka - 590 018 © Visvesvaraya Technological Univ a Scheme & Solution Signature SrRcrataizer Subject Code: [¢ C43 we Question Number Solution Pima F gy) Okan back of Static method by static — method : im fined amount of memory 2 allocated! , @ a W) freee: free( eh); v" » Fink binady -search(ink ray ie OD: on ) oid main Link Link toss thy fers Kyat 8c abe) a MryP As st (ws igh) . eer NTs “fd" ¥M), Sack = [Jors lps ink (: camenti"}] phy IF (deg >= Ofrmid]) Aatiarr mA; Halves v0; 144) 2 (Hy allocate) @ is abot , tA ta membas of to Hivckile yaad ntnbetd unity “) eee aie ©) snibeligahion Gn not ee Sean de trata da’) Selection Sok 1—- selection Sort pid maint usr) sateck -Sovt (int wy, ink LJ) on ay Unt 4, Pdr temps ™ nthe ne yn wens tt) pees ee) lo Sent ("/d", ¥n), P&=E, POE t (erfay Bhomenty ")” (ister EO feoreniet) |e Ls t(a(y] cafrs]) resed Stomp (“f3", vapry) select -Sort(n, a) emp = aD] PACE (" Sorts Elomenbs ate [Y alr]= fps]; 48 (i205 KMD) pind: re int 2, 3 J. m ) Conca Bb) Penatin of He Shing 9) ona eea(ci Si, chal SOL 3) void tengtn (chor sity) Liat id Litade taunt 28,620 j while (str[t]4 =e") Gy while. (sh (J, = Ge!) ety itty = ai faGeaseoBly We! ict) { mie OSpurte df= std i pint fang ta A" Count), * e ag aching MAX TE PMS lo} MC) Findude Void maint J ink abe], U4 leg, Hen ym, n)k-0,key, PE (* enber number f md"y ede f Struck *f ‘unt Mey e eA TERN; ) end | Lafolr=m,apheen; a7 48(i=05 i _ Priate [> tay ey domint"); Stam (8 of 3", wey)» seach( ), Perey, 6m Subject Title = Subject Code : . peecion Solution ae umber Allocate 3a) stack £ LTfo dala stwebute, Tnaehion sdlelon yo peprmad from We dere oe 2nd Collet 40P End Gk fy Non-Primitive Linead lata shucloe . erdabne |ss H#Aefing SOS Go rahi ink 65), f0P.i, im, afte - Void push) Void maaC J af (isp = =Ss-1) apa om Ilroenie —gktgn : d Bly +top]= item, Qriatt[* ): push , Life 3dioply| init"), se $ Pritt (“enber here “)," fe Pept ) Seong (“73 ¥ cA), at (bp == -1) Switch (ch) ‘ox tF [stesck Exmpty),” tn, "1 coe 1: pal) byeay Thlidel ete dnd", aLp--]) — }. Care Li popl); Noid caplag( brea, x wk 1 Extra Lirplese dy break, falico; 1S PPLI+F) Xnte (Sdn OLED, Met Suitle), ) C247 j gt 3b) Wan: (area) rere) (Dente: x by $2 eve) a. Pacfin , ABC-DE FEN Y — potthn: KYZFRM-N TPA r xe 343=6m 3 F inckide SLror -J) fag Compute (Sym Lat top) 44) bel, of 1072); 33 "Subject'Title : Subject Code : : ae Solution Ne hay Bars bacic of pater ute, errs } VY 1am se rp fo asl, guscation from 7408 Encl & Wok foisible , Eventhough “Hate do & SPace avaulable jak the front ind. us absadvantam Bon be OVE Gme wale UWule® Queut- prindudt . Noth wuss — freakC | void dab-Tearl ) Not 4 inteak-YealC on (f>28 gi 2271) t aon se ak fq eter) cite? Tuk ftanene vod ona: Prntfaume 40h eee ‘ — aw (47°) port (det eters a fi0)-Jj gga items siters HPO i apayeites dance front (ection not fbbible'?, Subject Title : - FQuesti Subject Code : uestion: ~ TF 3 Number Solution tae iy wid dele Frentl 7 gator [Oy | (itty) ‘ . aS {print # (+ queue enfty cone 13 PUI (‘Ener idem Sebatas Skomt (fd wiser), pant e(oaat lets 17 aft 9), eet x Lém at(fov) feos pa tt (eee fa" Biden), Void mour | ml eee eet Lik ch, Heer #3, VE), ben ae ' fei reas Ted Coe b del Yor di $AGi) | pAholter defo Omitted; 3g Re poyd uk front, 25 OF Gitmt} Pet Oe ti aD gatiay puint# ("ebay nerce')’ stent (fd FAY ro) Quek uae Sigly doped at funcki ont Pare sat. frat Oy _ fie rm jase — area 2 A OY peeks (prt dl - prot ) display C2 ar olplagl J, WoDE insert -¥eor (i,t iter, ODE frst) Lone emp, Ch; ten = (mba Trialloc (ised (st vot neole)) oe temp 2 in for Sims dee temp > link = null; af (frst == vole) Aihara kere wr 2 firsts while (luk > link Jeonved) Lau 2 tuk plinky 3 ug > gue = on cy, Aebarn firgty 3 No ~ Fro No Ss dE fron li DE rst) yo n oel t Arb Kyo ocke L mde semp, 3#( RAK =2NvtL) fone Sprint [© big . fat info; Bechara; opty struct node phic; sap rats tel truck nook 7 wodey emp Peep 2 abi es print [odel ebifel®, Arak heh) wid maid ) . tes (sra : nore frst = null, | 3 va Pups os chiles ale (1) wid dapleg (mene frat) q | Lene Poop print sires Hand chdeke front, | at (fit == wll) giclnplog , git”), § pratt (* Loot "),- pant ("enter choice Wy ners stomp (\ £3 YA) ahontp [reetints ote Steh(Ch) 2 fats / ws | pep ow) coe | pret (el ifern 4 punt (* fds gempriab) Stomt (“/4 y pik), Jemp2 emp slinky Fates inbett Yeas [item bras 3 / brary 3 lave 2: past = del Hoot (frst), brtak,” Core 3: Ansp lage), | brtat,’ ae Suit (0), ltl), 4 | 5b» Void Seaath (jak = bratky y NODE line a Fer, node frst) TF (fyak ==nule) x PAE (Lat ay Son ot») Atbntn j Emp) Gug2 firshs rotile C tug | once) x SF (Hay == Gd info) break; lad = Gud Link; tt (Curz= null) {print # (“Seatdh eo unsaccers full") arbara/ Brat ¢ (*9tatch 4p paceespt"') 3 BE) woré dal inrfoliat Mem, Nope teed) —= Genet} dnere prev, cur, nent tree (au ),’ i¢( head Qrlinx ==head ) Bokuyn heodk,’ L print t (* Lt trmpty") Ya head j j ot ahead y¥links while (C4 } - least) {oF (item =A yinfo) brag, U8 = GA Blink, 3 af (et == heact ) Uprint t (item nok tard"), Actayn head ; priv= Ca JMlinky nent = Gk s1Vaks ba » sab buat (ope frst) Lope cus tak count 0 ; at (Free nute) { . Priat$ ("rember ef. nods 0") a fa, 43> frst, veil Cus b= sult) Leount ++ 0 2 G8 Slink, ters lounk j § b ( See | Lore emp, G8, Yemp= Gtio node ¥) mnadloc, (six (std necke)), puget - fro nk (ink item, ope Mead ) pempainfo = 17 Kary syrlink j seUink = Jeg, b | 5 |line = head; — (tpxe-8o) emp -) glia = O44" | lak 3 |Link =Hmpy Refer heal,’ 5 ] head gilinks PIM/ ynere del veo (weve Wal) | rey oitak = head Pant OL hel Ele bo Ad” GR ink | 4 {Node cd, PIV, a (head 9 Unk =S haod ) proth («lob ”),' Aun evs 3 uz hand! > 10K reve ag 2 Iba ree (044), m OE) NDE Qty add (nopE a, wore b) 7 Tere c ewolly lak Coeff | while [> | wuld 6b} uve) —- Bald Leitch (doompare (42 Safin b> yen) wast 0 wet cat weHfe b> Off re (cock 422) czattach (wneth, a-repine ©): ack alary bobolnky bre coach (a3 toch 09 pS) az az lak preak, ere Stach (boeett , ©? expong), “ bob 2 lines hide (04? wie) {o- attach (on tectt ,2 9m" 12) Coke) * pon pile (b! swt) 1 attacs (220 bompen 1c); hob Duak, et Cs yn gale a en NODE drat) sink SP af ( frst =o null) Babar mp; Gare fraty idle (Cat link b2 eo) g Cauk= GA heal a Gaie = Pm,” Pekinr ny Araty 4a) / (i) Skate ee’ Sieryest We ve Commoting of oly left i Re ight pubs tie ot A @ 28, € Bight Stewed bre ett Stewed! Bez ‘ AT) (yecem ) pia J Yake=Pmp; i) wed youre (tab ikem nope Aoet) Tyrag e Hemp, C8 YOY seme = tive 0b) moods (S-edige (lroetnocte)) dnp ainto? jem, naa = NUH pnp ye unt = nuly 4 (ort 2 wull) LbatakemP, prey = null’ td = Foo t; tdide (lod yew) L 24) F Piven pur tao) ~ Qug > GA) Waly phase Uday wie ote) | 3 ga) mepe tart (ih ira wepe rev) / —3~49 | {wove mp,ud , prev dar br fio); we et Yong 5 (stwet node-#) malloc (1 #5izeep (stro Prcele)), Emp >in for Wen} yemps Hine = Hemp 9 vale = Neb; H (wot cenvit) Atbara Sony Phat + (° Eby rection) Stomt (“J ", Airechen ): Prev =NVLL; Wud = ook; . 5 fy (peoj 1 tilen Lirechon) MFA) | \ot( cu == Nuct) brea; Youve ay ! v4 (aiacctio [1] == 'L aK =Ht >) (nk ' ORs = cut 3 Yuide; 3t(an } = ole I/F J = Stren Girechony) \painkt (treat aot parnble J” itd tak; tt (dissection Fi-1J + i) Greys [lae= fnp,’ sai - WWale= km,’ Rabin oot; | | 8b) Void. Preorder ( nod ook) Lat (toot == Nut) Retry {an3260 ) 6 [4 " Reel > info); Preordes (Foot >Iiak), PreorhA (root Yr link), void — patorche (mE Yo) Lat (‘soot seutl) &itstn ; alia porter (rot JIUak)),” Pestoveles, (oot 3 rUiake) ; / Pint (' fd root lah), oid {norde, (node ot ) en (vt c= null) akira / inorder (Yeot JIUak) ; Rit Oa" taht ain) Votes Croot > thee,” SE) euphin traded Varro Teg —~ Genes oe) The” hte optationy —Comeivs ) W fread) (6) £Sconf( J, (4) Frorite( > 4} fei : (2) fopent ) - Ye) tebsec y fai CS) foarte db ) sted node a Lia (fem, yoid maint.) * Strock node # Uns “ted srt nokt uo Sink afiey,n,° lak Depate (tat Hem, ink J) pe ("ender 0 F notes" sep) ¥n), Satan ( Cem [Cont eH (08d -D) ACD i lesaur(int af J, iat) FA(i2ei (<9) cre) a SF d", HOfiT) big cafes; Pradkix(a,n); fA (ie eSNG itt) priatt('sabb 4p et (a0'7 rbig) big7edT/ : Fylaen big/ Hh (veo SS nzier) } putt yd", a) wang radin (le aL3, et 0) gerne >, Link jj ym) 00 big AIO . : NODE p L1e], mrp - (6 ™) big Lesgest Carn), melog.o( bi D t/ $8 (J215 1g mid Upa(ssoi e8ai O44! jJesueG rend et) Lagit = seeoe8 (f5,j), (apt smatrzacid, plagity, pros £8 [5207 vorrrr) {4emp =P Uj ) tatile emp), onl So tod zemeonts emp sep UF teas SE MSI2s bt, 78196, 81, 3, a : uifs2 # ex) [él ape - §m. eet 98 S 4] 4 24,27, td 52, 63,64 FER 96 Ae) void jnertion Sort (jak wink O05) Liat 15, pm; 48 (i295 igm-ls it4) Vitem=ap Jy — 6m f-) sfilapyinns eagyJeed7%e) fafyrd= ofits Ja Log) Wold bésCick Ud printt (“a”) ¥), Link fel, $20, 2° Waike Sues Pint E( pocket jeachable from fd") Ulery: _ bm Visited Fuge bs v Vit tr = 4 void mainc ) Wk (FS ¥) L cane yead i] P, basa beer) best), fA(w2L Veni vtt os 19 (aqujivd==! ag, vis KS LY] == ) 3 1@b) aya og croton adh atenty Lit Grs-6m) 6 - # = 8 ‘i fi | aoc BN D cf] He 4s +- GN D! Helps \@D Ahaition ¢ Hashiog —— (6motEs) Hash Haminology o "hash fale, Liu feetino. pant Fy hagh Gollemen OPM ackdsoyys cpt ball halla J a 1) 1 t to \

You might also like