1 / 11

Graph Representations and BFS Analysis in CSE Lecture

Explore different graph representations, adjacency matrix, and list. Learn the runtime analysis of BFS and space complexity of adjacency list. Be quick to earn bonus points!

lodge
Download Presentation

Graph Representations and BFS Analysis in CSE Lecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 14 CSE 331 Sep 28, 2018

  2. HW 4 is now posted Note: Bonus points for the fastest submissions on Q1. See WARNING though.

  3. HW 3 solutions at end of lec

  4. Today’s agenda Run-time analysis of BFS (DFS)

  5. Stacks and Queues Last in First out First in First out

  6. But first… How do we represent graphs?

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

  8. Questions?

  9. 2m = Σ u in V nu Rest of the graph Give 2 pennies to each edge Total # of pennies = 2m nv=3 v nu=4 u Each edges gives one penny to its end points # of pennies u receives = nu

  10. Breadth First Search (BFS) Build layers of vertices connected to s L0= {s} Assume L0,..,Ljhave been constructed Lj+1set of vertices not chosen yet but are connected to Lj Stop when new layer is empty Use CC[v] array Use linked lists

  11. Rest of Today’s agenda Space complexity of Adjacency list representation Quick run time analysis for BFS Quick run time analysis for DFS (and Queue version of BFS) Helping you schedule your activities for the day

More Related