225_31_BFS - Ifthedatastructureforagraphis:...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 If the data structure for a graph is: A: adjacency matrix B: adjacency list- sorted lists C: adjacency list- unsorted lists How long does it take to do these operations: Insert an edge? Delete an edge? Determine if an edge is present? Traverse all the edges of a graph?
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Adjacency matrix:
Background image of page 2
3 Adjacency list:
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Graph Traversals Two  c o m m o n type s  o f g ra ph tra ve rs a ls  a re   Depth First Search  (DFS )  a nd  Breadth First Search   (BFS ).  A pre o rde r tra ve rs a l o f a  b ina ry tre e  is  a   s pe c ia l c a s e  o f DFS  a nd a  le ve l o rde r tra ve rs a l is   a  s pe c ia l c a s e  o f BFS . DFS  is  im ple m e nte d with a   s ta c k, a nd BFS  with a  q ue ue .  The  a im  in bo th type s  o f tra ve rs a ls  is  to  vis it e a c h  ve rte x o f a  g ra ph e xa c tly o nc e . In DFS , yo u fo llo w  a  pa th a s  fa r a s  yo u c a n g o  b e fo re  ba c king  up.  With BFS , yo u vis it a ll the  ne ig hb o urs  o f the   c urre nt no de  be fo re  e xplo ring  furthe r a fie ld in the   g ra ph. 
Background image of page 4
5 Q ue ue  (us e d fo r BFS ) http://www.ac-nancy-metz.fr/enseign/anglais/Henry/bus-queue.jpg http://devcentral.f5.com/weblogs/images/devcentral_f5_com/weblogs/Joe/WindowsLiveWriter/PowerShellABCsQisforQueues_91 9A/queue_2.jpg
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2012 for the course CSC 225 taught by Professor Valerieking during the Spring '10 term at University of Victoria.

Page1 / 29

225_31_BFS - Ifthedatastructureforagraphis:...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online