lecture 14 cse 331 oct 5, 2009. extra lectures on proofs tuesday 5-6pm (jeff) wednesday 4:30-6pm...

8
Lecture 14 CSE 331 Oct 5, 2009

Post on 21-Dec-2015

215 views

Category:

Documents


2 download

TRANSCRIPT

Lecture 14

CSE 331Oct 5, 2009

Extra lectures on proofs

Tuesday 5-6pm (Jeff)

Wednesday 4:30-6pm (Atri)

Commons 9

Prefer my name to Professor/Dr. RudraPrefer my name to

Professor/Dr. Rudra

Next Week

I will be out of town

Mon+Wed lecture by Hung Ngo

Mid-termProctored by Hung and couple of Ph.D. students

Sample mid-term will be handed out on Friday

Jeff’s recitations Flat tire todayFlat tire today

Scribe needed for

Wed

Scribe needed for

Wed

A BFS run

11

22 33

44 55

66

77

88

11

22 33

L0

L1

44 55 77 88L2

66L3

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

A DFS run

11

22 33

44 55

66

77

88

11

22

44

55

66 33

88

77

DFS(u)

u is explored

For every unexploredneighbor 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

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