Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 15 CSE 331 Oct 7, 2009. Mid-term stuff Chapters 1-3 in [KT] Sample mid-term (and graded HW3) at the END of class The web version has the correct.

Similar presentations


Presentation on theme: "Lecture 15 CSE 331 Oct 7, 2009. Mid-term stuff Chapters 1-3 in [KT] Sample mid-term (and graded HW3) at the END of class The web version has the correct."— Presentation transcript:

1 Lecture 15 CSE 331 Oct 7, 2009

2 Mid-term stuff Chapters 1-3 in [KT] Sample mid-term (and graded HW3) at the END of class The web version has the correct spacing Proctors Hung NgoSwapnoneel Roy Yang Wang

3 BFS Implementation BFS(u) Discovered[u] = T and Discovered[v] = F for every v≠ u Set i = 0 Set L 0 = {u} While L i is not empty L i+1 = Ø For every u in L i Consider every edge (u,v) If Discovered[v] = F then Discovered[v] = T Add v to L i+1 i++ Array Linked List Input graph as Adjacency list

4 Today’s agenda BFS implementation runs in O(m+n) time Can the runtime be improved? Topological sort (?)

5 Reading Assignment Sec 3.3, 3.4 and 3.5 of [KT]

6 Directed graphs Model asymmetric relationships Precedence relationships u needs to be done before v means (u,v) edge

7 Directed graphs Adjacency matrix is not symmetric Each vertex has two lists in Adj. list rep.

8 Directed Acyclic Graph (DAG) No directed cycles Precedence relationships are consistent

9 Topological Sorting of a DAG Order the vertices so that all edges go “forward”


Download ppt "Lecture 15 CSE 331 Oct 7, 2009. Mid-term stuff Chapters 1-3 in [KT] Sample mid-term (and graded HW3) at the END of class The web version has the correct."

Similar presentations


Ads by Google