Lecture 17 CSE 331 Oct 8, 2010
HW 4 due today Q1 and Q2 in one pile Q3 in another pile I will not take any HW after 1:15pm
Solutions to HW 4+ graded HW 3 At the end of the lecture
HW 5 Has been posted
Sample mid term Has been posted: a blog post soon Don’t read too much into the content
On Friday, Oct 15 hours-a-thon Atri: 2:00-3:30 (Bell 123) Jeff: 3:30-5:00 (Commons 9) Alex: 5:00-6:30 (Bell 224)
A theory workshop this weekend
DFS(u) u is explored For every unexplored neighbor v of u DFS(v) A DFS run Every non- tree edge is between a node and its ancestor DFS tree
HW 4 due today Q1 and Q2 in one pile Q3 in another pile I will not take any HW after 1:15pm
Questions?
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
Today’s agenda Run-time analysis of BFS (DFS)
Stacks and Queues Last in First out First in First out
But first… How do we represent graphs?
Graph representations Adjacency matrix Adjacency List (u,v) in E? O(1)O(n) [ O(n v ) ] All neighbors of u? O(n)O(n u ) Space?O(n 2 )O(m+n) Better for sparse graphs and traversals
m ≤ n(n-1)/2: why?