0% found this document useful (0 votes)
9 views12 pages

DS Week 12

ds week 12

Uploaded by

bonthugoutham
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)
9 views12 pages

DS Week 12

ds week 12

Uploaded by

bonthugoutham
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/ 12
235C1202- DATA STRUCTURES WEEK -12 Lab Session: ihe Session__to__ Date of the Session: _/__/ eon Pre requisi © Non-linear data structure! | * Graphs having edges and nodes © Structure definition for nodes © Traversals of a graph © Shortest path algorithm, directed graph that corresponds to this adjacency matrix: 2.Define minimal spanning tree? MST 448 a gebvet He eds + a conneded ) en's hted greph — uwheds —cenreds ol He vedicer — duscther utter ony ade R minim total edse welshis. 3.Define adjacency Matrix of a graph? Ace SACO maltn Ok malt, oy whith ds edge fom ore vedtr AD othen gap eed ak os S47 abhor wire oo *Q’ 4. In How many ways you can represent a graph? Adjacent, mebrix | toked List » ify Aen Seanad ith Comscaner 238C1202- DATA STRUCTURES InLab Task 1 Construct the adjacency matrix and adjaceney List for given graph ? | J | sentation/iworiald Link: https:/Avww.hackerearth,com/prac Program: mje HL 8 yt Joann nr) \ 06O _ 2! 0 Oo o \ ' \ 0 oO | w) o 1 oO o Sample Input and Output Seanad ith Comscaner 238¢1202- DATA STRUCTURES matrix given below. A non-zero v djacency Mex in the column and apply DFS tp 2.Construct the weighted directed graph represented by the adjacetny 7 at [row, column] indicates that the vertex in the row is adjacent to the the graph A ecve RADE A05800 B30600 co3 410 po6700 E00000 Solution: 192 Seanad ith Comscoer 238C1202- DATA STRUCTURES, 3. What is transiti transitive closure? Construct transitive closure matrix for given graph? ‘Solution: HM, hosd et Trawitie doa jo defred os dhe he path bebeeen le were wa one ap o fo 70 9 8 1 fio! ° 2 | oO \ ° 2 Jo 0°° 2 o 1 I 193 Seanad with Comsconer 23SC1202- DATA STRUCTURES Post-Lab Task 5h? 1 Apply Prim’s Algorithm to generate minimum Spanning Tree for the following grap! ‘Solution: . ay nee Uwe eet AG herent] vot Cote 8 © ; 6 le ©) hq 9 aot 3) '* qt veishk > joxtt? avelts VOT = ae “st . 194 Seanad ith Comscaer 238C1202- DATA STRUCTURES and 12 edges. And you will create a minimum spanning tree Twill be 6 and edges will be (6X). 2The graph GO, E Ww Ee E) given below contains 6 vertio 3(VE) such that the mumber of 6 Graph G(V, E) Solution: - Leg KKrechhal Alge nth: Elye a gerkd odde: Cae wrest . PA or £_{p) e-€ \y 7 are 2 © 0-F aT € Q c-F om 3 c-¥ 4 p-9 6- Yer, ah do posible ge dieeck Ae B ae a MST atthe 6 £ edsa a Ale g° c. TR abe AIT Ab he answer. 195 Seanad ith Comscaer DASCLIOD Oth SRE Vind the Trnsitive Closure for the following Dingraph QE © .O) af\ yo J b ,oyo ood o0o0°0 °°? (ot 4 4 Disconnected Graph, Find the reachability /Graph Traversal using DFS or Depth First Scares start Solution: ee ee eo: . 25 0—> | -—y 2 196 Seanad with Comscaner 1238C1202- DATA STRUCTURES 3.Find Mini, inimum Cost Spanning Tree (MST) ofa given connected undirected graph using Kruskal’ algorithm Soli Edge? Else vt mt ja an y-2 3% 3-2 3~ | s-) de | y-3 5 * | a-6 tr 3-6 &* | gow 1% | MST: Hain Cyt 2 M+here Behe a 197 Seanad ith Comscaner 235C1202- DATA STRUCTURES 4.Prim's (MST): (MST): Consider the following graph as an example for which we need to find the Minim ‘um, Spanning Tree (MST). Xt ©) | “ | 4 i \ “O@- @- oO Example of a Graph Hrorltet Qei3 FF 7 i 38° => 198 Seanad ith Comscaner 238C1202- DATA STRUCTURES §. Constr "1 Het the adjacency matrix. and adjaceney List for graph given below? ® Link: q Ink: httpe:// www hackerearth,com/practice/algorithms/graphs/zraph-representation Program: Adjacerg Prod tOr e Taye 2 24 [ ote) 2 tay e 3 o1 oO ! 4 {Oe Adyecenty lots ALA 27 Yy ALA 1-3 AR D294 AI 193 Sample Input and Output 199 Seanad with Comscaner 239C1202- DATASTRUCTURES 6 Find the MST and it’s total weight for the given graph using Kruskal algorithm? Solution: Edges yn ecend'es onder: ce no Ease weigh — ie lo an. o 4-3 Ve “+ 4 a4 \6 wv gor J o-% 22 em PS Sf p23 8 ve @ éée vi FHT Kynoned , coz for a wade 200 Seanad ith Comscaner 23SC1202- DATASTRUCTURES vi \-Q kyrored peor it jor a wade. Tod uveisht= oa 25 rd r2ar4l6 ~ 72) (for Evaluators only) ‘Comment of the E\ Gf_Am Evaluator’s Observation Marks Secured: out of Full Name of the Evaluator: Signature of the Evaluator Date of Evaluation: 04 Seanad ith Comscaner

You might also like