Lecture 14 CSE 331 Oct 5, 2009
Extra lectures on proofs Tuesday 5-6pm (Jeff) Wednesday 4:30-6pm (Atri) Commons 9 Prefer my name to Professor/Dr. Rudra
Next Week I will be out of town Mon+Wed lecture by Hung Ngo Mid-term Proctored by Hung and couple of Ph.D. students Sample mid-term will be handed out on Friday Jeff’s recitations Flat tire today Scribe needed for Wed
A BFS run L0L0 L1L L2L2 6 6 L3L3 L 0 = {s} Assume L 0,..,L j have been constructed L j+1 set of vertices not chosen yet but are connected to L j Stop when new layer is empty
A DFS run DFS(u) u is explored For every unexplored neighbor v of u DFS(v)
Today’s agenda Run-time analysis of BFS (DFS)
Stacks and Queues Last in First out First in First out
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