0% found this document useful (0 votes)
319 views29 pages

Dsa BCS304

Data structure qb Bcs304 vtu

Uploaded by

gaganrai2005.05
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)
319 views29 pages

Dsa BCS304

Data structure qb Bcs304 vtu

Uploaded by

gaganrai2005.05
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/ 29
i @B6S Sensis j BCS304 usN Iho] 2 calol ols | ' , 2024 emester B.E./B.Tech. Degree Examination, Dec.2023/Jan Data Structures and Applications — Max. Marks: 100 Time: 3 hrs. i ule. Note: 1. Answer any FIVE full questions, choosing ONE full question from each module: "Course outcomes. 2M: Marks, L: Bloom's level, _ Module=1 Ht tr tcor QA Ta. | Define Data Structures. Explain with neat block schematie different type 0 ; data structures with examples. What are the primitive operations that ean BE performed? 5] Li | cor b. | Differentiate between structures and unions shown examples for both, © | What do you mean by pattem matching? Outline Knuth, Morris, Pratt [5 | L2 | COT pattem matching algrit. ‘OR Q2 Ta. | Define stack. Give the implementation of Push functions by considering its empty and full con ), POP () and display ()] 7] 12] COr b. | Write an algorithm to evaluate a postfix expression and apply the same for | 7 | L3 | COT | the given postfix expression 6, 2, /,3,-.42, "+ «| Write the Postfix form of the following using stack 6/13) Cor @)_ANBYCHD*E)+F ii) (a+ (be) /(A-0)) I _ Module -2 Q3 Ja. | What are the disadvantages of ordinary queue? Discuss the implement 12] coz of circular queue. b. | Write a note on multiple stacks and priority queue. 6 | 12 | Coz «. | Define Queue. Diseuss how to represent queue using dynainie arrays. 6 | 12 | coz ‘OR Qa [a. | What is @ linked list? Explain the different types of linked lists with neat) 4 ]L2] C2 diagram, ». | Give the structure definition for singly linked list (SLL). Writea C fanation | 8 | 13 | COz to, (Insert on element at the end of SLL. Delete a node at the beginning of SLL. | Write a C-fanction to add two polynomials show the inked la [ 8 | L3 representation of below two polynomials ee) C Module—3 Ea] Wille « C-function for the Following operations on Doubly Linked ty 2 (DLL: ly Linked List| 8 | L3 | COs (addition of anode Gi) concatenation of to DLL. B, | Write C functions for the following operations on ceular Woke (Inserting at the front ofa ist aS) 8 ]13 | cox | Gi)__ Finding the tenath ofa circular fis a Tot? Scanned with CamScanner BCS304 . For the given sparse matrix, give the diagrammatic linked representation, | 4 | L3 | CO3 2000 4003 A=|0 000 soo01 | 0060 OR Q6- Ja, | Discuss how binary tree are represented using, 6 | t2 [Cos (i) Array (ii) Linked list », | Discuss inorder, preorder, postorder and level order traversal with Suitable | 8 | L2 | CO3 recursive function for each, c. | Define Threaded Binary Tree. Discuss In-Threaded binary Tree, 6 | £2 | Cos, ss _ Module —4 Q7 Ja, | Write a finction to perform the following operations on Binary Search Tree] 8 | L3 | CO4 (BST): (i) Inserting an element into BST. (ii) Recursive search of a BST. ‘b. | Discuss selection Trees with an example. 8 . | Explain Transforming a first into a binary tree with an example. 4 OR | Q8 | a. | Define graph. Show the adjacency matrix and adjacency list representation | 6 ] L3 | COd of the graph given below (Refer Fig. Q8 (a)). Fig. 08 (a) b. | Define the following Terminologies with examples, ry 8 | Li | Cos i Digraph (ii) Weighted graph (iii) Self loop (iv) Parallel edges cc. | Explain in detail elementary graph operations. 6 | L2) Coa Module ~5 Q9 Ja. T What is collision? What are the methods to resolve collision? Explain linear | 7 [L2 | COS | probing with an example. . | Explain in detail, about static and dynamic hashing, 6 | L2| cos ¢, | Discuss Leftist Trees with an example. 7 | L2) Cos OR Q.10 | a. Explain different types of HASH function with example, 6 | L2 7 Cos b. | Discuss AVL tree with an example. Write a function for insertion into an| 6 [L3 | COS AVL Tree, ¢. | Define Red-black Tree, Splay tree. Discuss the method to insert into Red-Black tre anelement | 8 [2 [COS 2of2 Scanned with CamScanner Semester: 1 Subect b Dela Stuchires and Applications Subjectcode + Boson, 4) Data Steuchresi- TH can be dedred 2g a method o- Stovtng & organintgg He data tems jn tHe comp udeals rome Data Shuchere Prtmaiwe. Mon~ Prt mitive. int it ?foak Linen ron~hnea chat fs bopowble ee eee } Ques Be Leaked lost a ophs Primebve } ~ The dete shuchures, Het ace clredly operant upon 4 machine devel, inshuttons, og: ink, Hock, Chor, * pion Primitive: +o Joe date clr cant be manipulated elev 4 maslune Level jnchubions ane cabled, Mon~primytre_ 4: - arrays, steuks, guess, finved lst: feos, Grephs operons ave. inserting, deleting, Merging, Sear Somoy C esther in Ascending oder or Descending order) | Scanned with CamScanner Ts Strusture, Union. oa shot Rayon. Union Fepword ie Jochen, Shovek a aia Cheoaieg tle value of one chongyn fle vale of one deda member will not aber — gates, if will afreet ottar- offes dat momber. deta members we con vehi e a member only one mamber bor ato time. time— stud dsc union alse t tat a; Sp as foot b arr tees | . feeb ; fainl; 46) FT ts tle fardarenfed problem in Compuder Science, phere te is to fod all otcerencee fa gwen peitern whitun a lavger text we sting. Void shingmabeh CD d ydile (skeet =e) : (PC she Cr => pat CAD) L itty ott? (pt (I= No) t Pease d 3 fos (K= 0; rep TK] = Nols Kat, ins) ans) = ver KD 7 $s Bes Scanned with CamScanner a) gs — *) Shou: Ft is a near date shutre in utuch thee Ae incected and Dolefecl af ae | top of He ahah ool void push) 7¢ (he >= n-\) ‘ viat £C" Cheuk i over Plo! a s "’ che. br ntf] cater an item) roy yal, & teem) tops) stk bof] = tems 3 Noid perl) Par) t print? C\ State is vadee flo") 4 one © pond tte port obemanh ish" sth) yer oid dezpley ( i Hope) én ats rs em’ » t (ie #f jozor ine) et se" steCi) ; Scanned with CamScanner ab) Evaluate a post fix oF fv 446100. Q >scan te postfix eapression fon (ft to veg <7 ihe Scanned. symbol 1S an pecan flen posh it onte He state >t 4te syne 7s an operator tten Pr cul poo sytibols fom He steal and essa 4. Aoperator> KAD > Repeat: step Rand 3 Hil end of He Cxepreasle-O, oe ee a > 62 = 3 push onto tte salt, Hon Seon next gyortel. 3 agen pesh to stale ey 3-3 push on fo tte stele. =o iy pope, R*H=B push onto He stale oh [3] B42 = & push date He shee la] ten fina prot fe He stew arson Scanned with CamScanner oD) Tnfix to Pofin :- Stav Rag () — FR xm ”C fe ACL AB aCe 8B ACK? RABE RCP RACK C+ RBCAD aCe AACeED ¥CAK ABCHDE CH] FACADE X + 7 XP ROCKDE RT K + ARCe DEFTEE 4), 0 Dever 74+a400* Cc = an a cr Ow Cae aw Cre ab C+Ow ab abe cx mY abc Ct abcx Crt abcx c+e aboard Cel Ce abcad C+ [Cr abcrde C+D] abexde- may) aberde-/+ Scanned with CamScanner VveiXMXaAncaKkr ot pan 8 + a % 3a) Dis sduuatenes of ordinary Queue 7 Tnserton £ detchon of elments we Ame eS 2 When Queue BS Lut we cant insert new elerond 1 Ordena Quatre. To ovee dome. has problem ye shaussl implement Greater Querre. \oyok eng C ff e- sadam) \ pfl"'c& is over fla!) 5 a 4 ( enter choke") Oba § date) ¢ (f== -2) f=o; ye GreDKsire ; ofr] = datas SJ 3 Vora doy) t g(fe=-9 pelica 3s vader Plow") ; tps oad te st of) df (fe =*) ferte-4; i (44 D7me; Ose > 3 Scanned with CamScanner Nord daplen cy \ ttees-y * pre Ca emt’) s eke for (ie Py tes t= G48) si) © pplsa8ts 900) pf (va egLi3) $ 3 Nore than gne stacks can be ymglemecte on a stele Gre dimenstend array Sine A uth aren can be equal or different. Dumber ef arrays can be fred or Nawping . Sige implementation consists of foo ams of Srre_ ob each arent con nol be predicts. Bounds’ don cls Hon. . ; bey = 70) Pf tte ith task 15 empty sp acbre -nanenwe apdefine manstut to elerreni memory £ msir¢}j Int top Cenap stad) 3 nd boundary Lmat ste) ) rn ny ” Scanned with CamScanner top oj = bovadey (ila 4 lex Ci= 25 jany itt top CO = basndeny > (meng si2e/n) ¥* i> Davndan tei = memonysrre =A} o 4 Bag 2 Gnd ies * sed oh bang) nl) boar tet) tpt) ty (3 3¢) Queen Tt tc a bineav datoshubere_ tq ubich jnsested ad ore_ ond cabled “rear 4 items Ss are ee ad another end cabled "font! endl. ceo a fenown oS FIFO - o\’}?ZBA SEF Telolelel@ a[s | £25, coy Flatten view of c&. Scanned with CamScanner om 2 ui & 2 FMW 3 1 1 + CID\ElFE|G 1 |B \ z B e+ 66 78 qd 'o I [ZL 13 1k 1S [ ( |_lele Hecnatve lon heron tat ea Uneas dade shuddave vetere elements om enked 4a) he we 4 eneh dimen oats fo Her nent rode. - 2d (n seg . i poakans doke F Unie Katds points He nent node a ode d ww LR cour 0 A (ast node potots to wurk in te Spe” i wl bel = aaah nade. has foo pointers: Bre and antes is to Aft bak. Scanned with CamScanner Grutuer ML = ene last rode 1s. anne He frst node. LTH can be ether St or oe Te | =} >|} | | 1b) Strutove de Bashoo | Bhrut nde : tat dada shud node slink; Stheat, athe phe = TULA § Ke Trsect an chment ab te ond ofisar Thanet an amen af teen of Sat Noid insestEad 0) ; pk = Cats) male (soed OE) pb (* batee deta!) cP Cys", 4 gee) bro data = mums eee yuh ; ff Cheat == eu!) head= ph? n " c head; vehaile Chey? bak 8 = a) =. deep Dunk) fog Deke tT Scanned with CamScanner ed bak |, 4 ? x Dadete beaioniog of SAL Noid dab bea CY 4 tlhead =- ae) x “rc ens omehy) s ele 1 ol clebees gcs head > kinky ph debe (828 fir Pee) 5 ’ feeleh)s 3s nd) payee Cath & teeth eb past foot, vee, tps ak sum vite (2355) Maite (dope L enge-a* alas C oF baunks cose 01 gunzaneedl + bao Gaurd) abtoah (com, a> emp, $1227) ac aol b= bodinks broads ; gach (a> ef, arorp §veav) aca lak; wen, weet) Lreet, b2efy Sree); beealt; casts Scanned with CamScanner Pod = 3,4! Bat. 2842 gD = axl 3 + ook > gle} > Gale [Z) ¢ | ul te 4 -Cele( x] 5a) Apprion & a node i) Void odd (node headvet, int 48) { node ne = create nelle (dat) AC (& hesdred == unt) 4 headvel enoanale s node ke ounrent phale Concent 9 next, = url) a paral et; yelvrn; = ehealred j Guerrent = naonede; Gaweentt a nett = cont y pednede > grey = i) roid Gncatinabe (shut rade + fest shut node send) ; A ght node FRE Best 5 hile (p> next J = nuet) e=t? nents 2g nent = sewnd} Seen d= mubhy B 5 Scanned with CamScanner Pe) i) ~ nyoidd cnsrt fant ( i headbred int ects) t ag _(inkeA LSS q noble & neonobe, = Crk nafe(datd ; mo f CthedeP == nun) 1p headrvel = newnede; Newacde > next = Mewnede; 4 ke node # Cost = ¥ head ref} pale Clast pret) = headee) t fast = lash > next 5 s = theadvet j newnode > next \uta next = neondde; Fhedveh =newndes ri, 5 ‘ . ) Finding Cen of Civotas WW} int (eg Coude heed) a fp lhed =a) pean el int dea = 97 pole xcars head’ dod fon 207 ase OF ‘ ade (ors hens) eon gh, x 22 nent; Scanned with CamScanner %) Field ld feet ~ bee pO | 0 | 2 \ o| 4- _{[ 33 3 oO ae 3 | af 4 | A al be qd [stale } he = eal (LS 7 A aS te —— of ol= ot 4 Fay tel Scanned with CamScanner a in ga Bienes) Tee Repssemie’es ' i) Weeeg ie Also catledl cequsatiad. Repregento in, “The nodes cre purrboered fom oto wn § One dimensional. av con be used to store tHe nodes oot node > ale) tef} mid > BAL vg dald > WW "fs i) findeed Wet !~ Lash node has 3 Aids teLfcbald 2 which Contains tte address of {eft subhee_ Dake 2 Lolwch contains He actual information, Regtand > wlach Contains te addrese of oviglt sulsbrea, (ean La @ 4 avo {Alda Peyote Tel] Bley Scanned with CamScanner Nord faorder (cfruut node. + root’) ; if (vod 1= wutt) mirder (wool 7 kf) font Ca", syoot > dda) 4 5 inorder Cxoet > stqeel) void prearderCshua! node se'voot”) a ¢ (ost } = wut) ' print Liat soot cle) decd vod 3 heft) ‘ preseder Creel 2 riyet) Bs Votd past poder Ce host noble 4re0) 3 d (xt! = wut) ‘ postorden (yeot eft): pastordee Coot 7 wieght) 5 pnt (7 rrool dD; 4a Tassel on Amal eh ST Ghost node © jnsert [chet node stroot » taf item) Lf (weot = rund) 1 yot = Cs bot node 3 mallee (seed hed melt); root > left = oat 9 rig = Urb) soot a data = Tem TT Scanned with CamScanner | poe d (item dette) qoot 2lef t= insert Crt a heft, tends dye ¢ Citem > woot 5 date) a Took 7 7ryd = insest (woot 2 vig, iden) 5 id Co puglate bund. net atlowea) i gebn weet! 3 1) Reamesive seme ¢= sfrusk node ge search Cs fet node. erve0t, Fe) L ft (xvot sewer 1 intl Cert fond) cued CH < soot -> data)" apefurn gear Crot-2 left, ke); aut Cleag > ved 2 dab) yeboen sear" Covet aright Fp); ee pecieg funa")s can Yeot 7 fo) Tixeaded. Biomg Free ¢— Sn yelach wet palaters ore leved. q re perenveg to vftor nokex inte free. cad. “Trends Tio Hype }) Leff-in. il) Rat in. All (eff chute polalers Hat ave pull poidss 4 HS inorder Aeeeesor. fel Reet chal pointers iad ove nul pointes iB order pe Cueee soo . 7 ‘Scanned with CamScanner qin 2 0 7G i Re | RET Tdet © OO 15m CER IEERN Del) 7) Selation fee t~ T} 1s algo catledl as Tou tna ment 7 “hes 1s suh a fee date shudure veleg vhuck He winner, & a Knock out tournament can lee soled A. Trew ore two tyre of bees. 2D Winner Weer = 2 yp a domelcte biney Tee jn elec wail Cur node vepreents gmatler of its two children, Thus soot node vepwents tte gmatlest node in te tree, Be R ~@ b> BAR, 1) Loose Trees? = Tn wdach non-Leaf node yetunsg a poster fo He loser: ® onvrath winner. Scanned with CamScanner fe) Teen aforman eee anto Biaaw Free f= Tf Ty tay tn is 4 forest teces, Han binary tee Goxreaponding to ttbss Leest, denoted. & BC Tr Tn) y as omby faze > hug toot fo woot CT) Dd hes hee sub bee epual to eCTu, Tin ~- Ts) "hag ~rteytat subhee QCTr ~~ Th. * feb bt al . ; Poem ee ese 3 Spee Scanned with CamScanner ad Digsaph i F greth wins e2g ove dnekes VA egie © >) wagered Greth { Edges have a werynt tt shy pica hows cst of hawersing, 10 qe SZ = SZ ao : farts and end. Tf is an edge velach ste nes yecten. in) SAP teers ace He same a NN) Paral Rige* 7 ae vefers fo fle moltiple eotres that thesame pat of vertices Ina arth Bone ein Scanned with CamScanner fa, _Greegh operations > ae yet Fraverse a gregh mn breadtthwarck clirecton BES, Ha newt verte Qusea e quae to comember be gee fo stata cearely. Mgt ay- Vet He agg ONE AN tk a Soir DP no adf vertex is fom tte rere Sate Repeate si{sr unhl Ques is empty. tec vertex, Marl vaited, Diseleg, ib Tnsest afin a Que, Band ! ieee He. Rest vert SDES+ - TH fraverse agraph tn depthioacd, Airedttog fuse | aster fe comember te get tee nent verter to Stet asggee! PEE a iit He acl} vnugited veto. mak ch 28 vente Papleg its Push th in a gta. ori fae adj vertedfound , pop ous for stat g3i- Repeata S12 § 82 vahl He stave is emely- 44) llision yesoly tion fs He process of handling aituateoas hore too by meee begs hash to, te same tndex 4 w hash table Mathes ar 5 Separate Chaining. Addr cag 1a « > open 4 qf Scanned with CamScanner # Linea Psobing + = Tf He calculated — gndex ; occugiet, move fo He next jnder + Ceep probing seg vent ay until an emply elt is hogs fanckon ~ Wek) = Chew +1] mecl mn here 1 is tte probenumber, om. js He sperble Sire ee Quen bays \2, 13, 10, 20, -+teeble sire “10 S Ye up SB an w) Store hashing: ~ flere fable gre ic fred Hirmalonck te dine He hash fateo, Th contains an aviay of Pirrah soe, where cosh clement in tte array 5 catled bultel o slot - Te hagh ban ch’on maps keys to jndiceg in Hus array, FE foo bys hash to He same index, a Gllisfon oceurs, _Dgnwmec hashing = Here sre df He hash fable cm — aumye degra cacy based On te number of elemeake stored 2 cE involves entendile healing, and. devectmry (eas hag lung -Tn extendible , imbaty iH onteans matt slots = Divedorteg 1— stores tle addreas of fle Lauteebs ~ Directories Bubs i- sed to hash He adual dada = Gilt Aegth :— Dene e. number of bibs whee ave used Gy hasty Pach Scanned with CamScanner p befist Base 7 A LePhist freee rs & bina bee gun frat rf tb po Nob empl then chocreat (lefidald OD >= shores Cgutdaldd ‘gq bemnal mode %. oy 5: far every, bet jefiaalded 4 4 da\ald. cuadren od infernal node Re THON ghortsd ps ad Lllows ath fern x te =} o & xm enter 14 men 4 Shortest Cleft nal node ; Gd, $ hoctat Crag h) dogs °°? 5 8 _ fh ters iteraal node Ww ie - Bi . ee coe re et ac apitah fo He ade Scanned with CamScanner \oa) Hash Rimetioos ee ) Division melbok i> We vee podular athymic Syston fo divde tte by value, by some integer Ainsor m \ - j2e=G {Hon hi Given Y eeees si i HO) = kay xsre ol = a3Kog ; = 3 __4 3/33. 4 - We Squere te Value of a ey of digits vvequiveh to form an () id.spuers Mele’ umber and tale Hen ‘ aaares, fom He mibdte position of squared Valtih: eqi~ key Te \6 we went address two thon square 1s. drgits dtlen we selet te address as Sb. ni) Clare Metied $- The key is achually partitoneh ere rte enh yt bang crmee a Te ee eee There Ore fwo woes 2 Fit unde qn loausizg > Dts toet7s= 180 ~ stabstical analysis of Agits of He bay ’) Digit Aoelysts / tte digits which our gute, Pepuantey and select Scanned with CamScanner j An five hee 4s a sdf —babanang binry free. a height halance property sus that the i m aintains I hog! Artlecence. fefvean te Left 4 wage sublrees of any node js at most 4, (39) ey 30) (He) Oe ge re of san te verge ance of ath nodes ore witten 9 Tee eas Be | Bae | ee te Lalaneal 4 He haghh oh He hee remains waar trmic- 7 2 a freee marntains He binary more bee tea, pr fee left subbee are Lees than He ) wget $ ah Modes in Hee orrgt cube ore greater yhoo apeot* chruat robe insect (sht node + nd int lees) 1 f fase) -celuen cat ley) j é&¢ zredepbeg) a ole = recent Crede-atePt Fax) 4 ke? (4y > nolerbf) rede aveget = wncect Cale Orit) ley) » nodes beh = 44 wat gethegtt (nodes el), getlayle ratey lat f= gd tain Coed); wD 2 | Scanned with CamScanner tT -balanes tod) Red sblaute Tree Tt ts a set 1 bipmy so. ' te iS ith He failowing preees a cearsh Tose 17 AU nodes ante LePe sub hee 1) Binoy Search “rose | von! are (es than nodes Nalee gubtree have yen greter hove W VW) Al nodes tn THe wt Han te poders valor sb octlase bein yer PT seh ie Soh noee \ Color! eotic Powers ; re St ts a self-adjusting binary Sear ree shee" teceged, eloments ore pure ee pore that Teer 4 wih anaes a. ° 7 goot » intelate’) Noth i nsert (node 2 node 2 = ctCdatdy j node & Y= Mubhs pode t W> # root 5 qultle (x) = wurr) Lo yen yard rt (24 den L. y-pdete) L xe rohePh; g . eke X= KP veya 5 $ s Scanned with CamScanner 12 parent ay it (4 =a Nun) Aevoot = 25 vee ie (2->date Aye dase) t Grdeft =25 5 Oe Y eee Bs £ a Lnsertion Crook, a 2» , ae HOD ne Computer Science & Engineering, KLS Vishwanathrao Deshpange Institute of Technology, Hatlyal. Scanned with CamScanner

You might also like