lecture 18 cse 331 oct 11, 2010. mid term next monday in class

10
Lecture 18 CSE 331 Oct 11, 2010

Post on 22-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Lecture 18

CSE 331Oct 11, 2010

Mid term

Next Monday in class

Mid term entry

Has been posted on the blog

Don’t read too much into the contentof the sample mid-term

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)

Feedback forms

Am still going through them

Images are more confusing then exact definitions

Lectures are vague (not precise/well planned)

Graph representations

Adjacency matrix

0

1

1

1

0

0

1

0

0

Adjacency List

(u,v) in E?O(1) O(n) [ O(nv) ]

All neighbors of u?O(n) O(nu)

Space?O(n2) O(m+n)

Better for sparse graphs and traversals

Better for sparse graphs and traversals

2 # edges = sum of # neighbors

2m = Σ u in V nu

Give 2 pennies to each edge

u v

Rest of the graph

Rest of the graph

nu=4

nv=3Total # of pennies = 2m

Each edges gives one penny to its end points

# of pennies u receives = nu

Questions?

Today’s agenda

Run-time analysis of BFS

Breadth First Search (BFS)

Build layers of vertices connected to s

L0 = {s}

Assume L0,..,Lj have been constructed

Lj+1 set of vertices not chosen yet but are connected to Lj

Stop when new layer is empty