Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 14 CSE 331 Sep 30, 2011.

Similar presentations


Presentation on theme: "Lecture 14 CSE 331 Sep 30, 2011."— Presentation transcript:

1 Lecture 14 CSE 331 Sep 30, 2011

2 HW 3 due today I will not take any HW after 1:15pm
Q1, Q2 and Q3 in different piles I will not take any HW after 1:15pm

3 Other HW related annoucements
Solutions to HW 3 handed out at the END of the lecture Pick up graded HW 2 from recitation/TA office hours next week HW 4 (and rubric) has been posted (link on the blog)

4 Mid-term related stuff
Sample mid term posted (link on the blog) Blog entry on mid-term exam prep.

5 On Friday, Oct 7 hours-a-thon Atri: 2:00-3:00 (Bell 123)
Jiun-Jie: 4:00-5:00 (Commons 9) Jesse: 5:00-6:00 (Bell 224)

6 Empty Slots Coming up…

7 Computing Connected Component
Explore(s) Start with R = {s} While exists (u,v) edge v not in R and u in R Add v to R Output R

8 Explore(s) = Connected Comp.(s)
Lemma 1: If w is in R then s is connected to w Lemma 2: If s is connected to w then w is in R

9 Also argued that m ≤ n(n-1)/2

10 HW 3 due today I will not take any HW after 1:15pm
Q1, Q2 and Q3 in different piles I will not take any HW after 1:15pm

11 Questions?

12 BFS all

13 Depth First Search (DFS)

14 DFS(u) Mark u as explored and add u to R For each edge (u,v)
If v is not explored then DFS(v)

15 Why is DFS a special case of Explore?

16 Every non-tree edge is between a node and its ancestor
A DFS run Every non-tree edge is between a node and its ancestor DFS(u) u is explored For every unexplored neighbor v of u DFS(v) 1 1 7 2 2 3 8 4 4 5 5 DFS tree 6 6 3 8 7

17 Questions?

18 Connected components are disjoint
Either Connected components of s and t are the same or are disjoint Algorithm to compute ALL the connected components? Run BFS on some node s. Then run BFS on t that is not connected to s

19 Reading Assignment Sec 3.2 in [KT]

20 Rest of today’s agenda Run-time analysis of BFS (DFS)

21 Stacks and Queues Last in First out First in First out

22 But first… How do we represent graphs?

23 Graph representations
1 Better for sparse graphs and traversals Adjacency matrix Adjacency List (u,v) in E? O(1) O(n) [ O(nv) ] All neighbors of u? O(n) O(nu) O(n2) Space? O(m+n)


Download ppt "Lecture 14 CSE 331 Sep 30, 2011."

Similar presentations


Ads by Google