0% found this document useful (0 votes)
8 views15 pages

Ds Graphs Assignment

The document discusses graph traversal techniques, including Breadth-First Search (BFS) and Depth-First Search (DFS), detailing their methodologies and applications. It also covers various types of graphs, such as directed, undirected, weighted, and acyclic graphs, along with their properties and representations. Additionally, it touches on binary tree traversal methods and sorting algorithms like heap sort.

Uploaded by

manaskhapekar5
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)
8 views15 pages

Ds Graphs Assignment

The document discusses graph traversal techniques, including Breadth-First Search (BFS) and Depth-First Search (DFS), detailing their methodologies and applications. It also covers various types of graphs, such as directed, undirected, weighted, and acyclic graphs, along with their properties and representations. Additionally, it touches on binary tree traversal methods and sorting algorithms like heap sort.

Uploaded by

manaskhapekar5
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/ 15
cn ee. | ‘oeplan graph traversal Copaph tyovessal fS the proces of visiting tach node fra graph ie Syste mache way . Hl. 2 fundamental Gncept Pr qaph theomy and & vsecl Tn rnony applitattons, Such ah Hes Of Gagh dsaversal> , There an several type af $sop D- Breath Fist toversol (BFS) BFS Lyaverses tw graph Ue by fora afiven Source node. R VBI ail nodes of . given depth , before Mo Ving to tha next ptt © depth-Fast pavesallOFS> pes traverses Ba graph by exploring OF far 09 possi ba along each branch before backboelcng, sThese on B-types of BFSS fg preoder DES Vitis Hu Gawent neck befove H's n&gh bours * Tp-ovdeds pPSe, Vistds thu tes TH5 Leet nghrbour ond NEP ghbo+ oe “ por-evdert DEES we Ofter tH!s ref ghbovr - py keaverall level, stork nay Coser noche before Hs HE Be: : # ee @ropoloateal sorts ~ & Recital dort 5 a \Preos Ovcluta, GH nodes, fr a chfrectedd acyd¥e ose CDA G) suah dat Pov every edge Cy, Node yy Comes before rode V tn “ Orduing . Slactithm og (pes) be Gheose a stating Node De Mosk be Satna neds Os Vidted Bo Exploye the Net@nbo vrs of He Stag Bracke. 7. 4, Reeureively repeat. steps 2-3 G> Backback +p us Prevfous node. . Alsgtthm C&FS) l- choose Stating rela QR, Creote GO Juoore. : 3B. Enguotte the Starting nook and. moke Jt O45 V9sftu. 4, frngpsu tHu_neale!s anvTsPheol nia fbows O. Tepeat Steps 9-2. : eo ae Applications® x Wehoork Bree & Studyfng the Shuchure and behavior of nehoorks , Such of Beefy nehoovks , web geaphs, and Fons portahton, nehoorks, x pathFindin % Finding the Show-test or optfrmal bthoeen hoo nody fra graph , Zuch af Tn GPs navigation System, ¥ data Pnings Distovering patterns ang! relationships 70) large Chafasets , Such of Gin Tewrmencatien &yster ad phusterPng algomthrn. fxploin Amany tree toversal Hh Prograto 79 50 Tava Binary tree tvaversal, 4s a process oF Visita earch nocle In a binary tree in a Eyplematfe Way . There ow three min types of. binany tree bras ewsal. Lou Ovchey 2, preo wader 3. poste rola. Tn orl i Legh Subtree ~ xp0% > Pre orders Onnrent neck > [eptsubhree > igre Subbree Leg subtree 9 Wigs ublrec +> Leorrent 2° Ze Pestocdey a eC ZeRogqra m™m Class node £ t Mt chato. § Node Leet ® i Nod Fight $ PUbL nods (Ant dota) f this. data? datas Pe ler t = null a ant = Aub, e Chas, Binoy tre § Node wots oe. BPnacy bree OF thfs-rmok]= Nut? public void froxberFravenal (nh t EF (nedle | =nult) ? FnovdlexTaovenal (node. Legt) is Sqstern.ouck pontin (nedle. data +“ 2)5 { noveleveavexsal (ned. Yighd) s % y publi vod. predrclerbaverial (Node nada) © €2 Crode JenuVE” Syste. Duh. printio(nede thatat® ” ) 5 preorder TFroversal Cnode. e+) > been Tanogd Croke. veylt) ¢ % publte vofd pestosces Troversed (Node node) $ aa) i Lode [= nut) £ postorcla Traversal node. leeh)4 resorcleRaveysal (noales vig 5 hyslem. oud. pifiniin (mode. data t* 73 % “publte class mnafr ¢ | pablfe etatfe void that ( shfhg T3018) f Bhhooy Free bnarylree=hero Binary Tree OS Markt), i tPnargy Tree» Pot lex faNerd Wodule)s, binany Free. 'woot=ne10 rincle C35 binooy Tree. voor. berfogice Res nero nocle('3)5 Vinar4 Tsee +yoot= lept.lepe= nun node (4)5 Dinanytre eo wote Legrerty le = nevono cle C52) Systernooud. print (“Thoweey Travewal?.”J % oany Free. tnorelaT raver sed CbaaryTwee.000)!| Syston outepvinin (9 Preorde yTravenal 2s ; Vnonivee - preorder Travenct Coinasy Tree, yon LS “plerm od. pietin(™ postood ey Trav sed UF Crow Tree . Posto rer Tanah binaryTece. woot) 5 Dutpet . Trev Transat 4 Ho si 3 Prepscter Voaussed f as 2 4 posto scley Traverse’, 4YS5234 Sort Algovtha: Explain The heap So Syphon 2 4. Heap est nai wy . oy si eee thet uses @ binaxy heap three to Sort -efements fh an anny, Algovthms “Suppose vee have Hu followdthg Unsorted a is 19 1.13, 55k, 79 Septe- Bd a Mar heap © Stavt woth the Lost non-leaf node 1/2129) and Perform ty NeaptPy operate YO ull Qe ar aoe) | Step2% Scoap Ye woot node woth the last Node 40 we resulting heap fs Y2, 12, 7S 7G, 134 Step 3% Reolrwe. tr Heap Sire by one OY | vernoui ney Ba lave rectal (S) HEP s- Hearty We Reolercead Heap aor heap fs [as pe, Beg b t Step Bo Repeat Step aH say, we ffral sorted away F [57 6,7,11 a (what f Graph 2 plat hipeenne types of Gpaph doth an Example. ) Goaph % 0 nertfreay dota Shuchive Conshhe verfices anol eclges ~ The Vertices ane Sonal abo vefermol to as nodes anol the eolge a nw or arcs thet Cornect foo necks fo the Graph. Tha graph f eenoteat by Gy E) toh Vert est V) and. edleycs CE). Verticess Natfces one tu -funde mental units SS 4 a graphs Sometimes , vevhted ons aldo Known as Vertex OF nocdu, e used to Connect Ede Tt ON be directeal Edgess, felger ane drawn 0 “hoe ache pf Ordred pot oF no cles 9n 0! qroph » é €clges Can Connect any foo nocls Pn Any possble Way: There ao 10 piles . Somuiimes, ed abso roe Od, Srtd « vee abated: Sion ey can oe wbuiey Me Of Geopht Zs malt qriphs pi f\ naph of order n and Size Zew ty, 5 a%agh volun. Pres one ovoly fealaded VersMees, udth no edges boom ete ony Pah, ef VerHires, “A null opriph has no CBdorbd Yor noly verter and no Gormeson Dehoeey, tharns ‘ HA nu crap % Obsc Enow ob COs. apeiph , Saoldded Cpraph OC & Ofecrehe opsaiph. e4E on @) @) &) no edges 4 22 Core he 2. aley ps udthh 1 VerHices Fs Called | 0 Compre pag £e Ae Soqree Sf each } Nettex %2 n-\, thed Is One Yestex Is adndad ith nat edqu of M4. oret of ths Vodice tn the Creaph T+ Fo Also Cal¥od Os -Prul opoph, fer Gi) vy ‘ J iiial Geaph A gagh 4% Caled o -vPal guaph IP *t Vax only ore Vestex prea fm It. he tov Pal wash % the Srrollesé posstlole geaph thet Can be Crecded yotth te Least gnumber of Vertices Anat 35 one Nevtep only nl bs ys 4, Non— Directed) Grevph ; A gaph fc Coled o non-chitrecteal graph Tf all ty edges pracnk behoesn Ong pap pods ane non-dPrectedt » By non- clitresteal edges pwe medn the edges of the graph thot Cannde be ArtermPned Gom the node Ft Fs Stavt fro fed A ei de te Uk oe edges of O non- dfrected cpap h don't have Atrectien - Bate - ) ©—_© 5. 0Prected Conehs- Z : & graph fe Called a ASrected graph or Morogn ff al) Be ea 5 prevent beboen ee or nocles he, gyraph om Aivedted | oy ‘hove a defined cltre San. BY aiveded eos) we TO COO ae eco? of the POP thok howe 1x Atxeetfon . fo dudenrftie, om Won qpde Te 7S Startino, and at okidh Ode | ® go ending. Ex a) @) © an ectges 4or a to tbl pt oa Air aaigh need $n be Afeed, en grap or Aq>ciph, | 6. #Pofte GQoaphs a The epaph G2, E) fs Called a thf, 4 opr te te number ap Verifoer and edges fy -the raph §s Wmited Pn number, © Q B® Na) Te Thetette Graphs The qragh fe Called aemnrte qzaph fe te Aumbey 8) Vertes and edges “tm He Grach 2 1S Snternftnabls. Sine Graphs De each Pats af Nedles 0% Mestinas Th a “graph hat “only one edde J Fane Sfp graph. As o welt, 4 Fo fest one edge Linked trom Vertfas, Cupicting one & te on Pilevathfon bio +00 elemonts. | MUHPGrephs Te thee are “numerous edges tsfo O. Poly, o} Vevifces Pn A qaph Gtv~),. The Graph fs wsefered fy ay a nultgeaph , Thane an no Seletoops fn a multgraph . U0 Feeds eeraphe : Tho GaP Ge OE) Copfoins q Belp loop nestebes oth. edgu - Ps a: Psetediocraph , My Regular Graph? PF % graph G=Cv,b) Fe a spk gsaph UH He Some Geqree at each Nevfer H+ Fe a *equlloy ara ph ® mp © G) ‘Fa, vodighted Goaph4- A gpagh % Called labded or og) Bagh becarye each edog hos O Nalue gy a wockant wepresenting the Cost 01° traverp i had ¢ Age "_6) Mol oe YS. Compe cted Graph | Tk Xheve Re a path ochoeen onz Vertey | *. Ga Graph data shuchire ond Any ota Negbext “At, G20~h Fs Connect acl, mH Dfsconne ched Goaphs BON SAO, ahs edo Unk Pro, the Verte, 2 4OU Yefey ty the pul gop ola fs connected avaph : @ a— em ns Sat Graphs Tt & graph Contains oF (cot one qoaph disele ons consicord tp be used lo. Acy fe Qraphe ; whon those Mle no bn in a Freph it fs Called an acyctfe graph ® © 1 © ) 17. Dfrected Acy lt Gaph? re TYsebno known os a “Es eke cd acy | Paph CAG), ond T's a graph wrth) | Abrected, edges ed no cya. Te vepresuts | te edlgcs usfing an owlereel Parr Gf Vertines| Since Pt ARrecbs the Vertes amat Stower Some labo ! lo se ; Osa -O 9 Subs qzaghs ae Ths Vertfees and edge of a grep Chad Subs cs oY awoth ey grace? Oe leno. a4 a Subxyyapn. L g ubgreiph NS) Boptath ye clffferent repretentiig Brmph fn detag with an ercarragh Ww €ath, » The graph repoesentalfons ae ri Aedfa cent rmabix AB capi ae S o 3 2 eae & 365 9 Gam —e > 0 Aa @ | 3 714 woe Elo oS Ge Show Wich Nedles one shee, thens any m behoeen Nodes Mm O qraph , Meu Create an BAX M rnabh?x G for This wep resaniation TE ay, edge exists bebo. Vertex g ono Verferb, The Co ~respornaling Bement 5, Aye t tHherwise 913) =o TE these fs 4 weighted Spaph, you Cay Wtord toe edges coi ut Pnstead a 4s and Os Tt F. ee UNATrectea Gpagy vepydienta - et), gon. arether Connect ay | 0 —— & i. NAF acency Ue A \Pnked fst. opt fan 4s an adie 25 9% Ben y eWsenbkecian You Keepa Uy, ertex On t Means b 7 : a. par the a SVAPh Fy AEs Re os “ach Nevtex am the qrap Tors FH 9 a Po St W's the Thora Ne i" fas Nea OF ewes Gf Vereen the Nextey umber, and ab Corres pond fig CR) oni ay each Nevter X Potnks +o ed st y x's Tubs wos | t—~—> B-—-se-—> pb x DB é GQ opnseBe ; fdlfaner ” aoe > is ok 2D ©

You might also like