Download presentation
Presentation is loading. Please wait.
Published byLester Hampton Modified over 8 years ago
1
Lecture 12 CSE 331 Sep 28, 2015
2
Upcoming Important Dates Tuesday Oct 8 (~1.5 weeks) Mini Project group compositions Monday Oct 12 (2 weeks) Quiz 1 Monday Oct 19 (3 weeks) Mid-term exam 1
3
Delay in handing back HW 1
4
5 min ask me anything Q&A Feel free to stop by and chat about non-331 stuff with me Director of UG Studies OH: Tuesdays, 11:30am-1:30pm
5
Today’s agenda Finish Proving n vertex tree has n-1 edges Algorithms for checking connectivity
6
n vertex tree has n-1 edges r r Root tree T at vertex r Proof idea (recap): Direct edges from child to parent tail head Every edge has exactly one non-root head
7
Questions?
8
Rest of Today’s agenda Finish Proving n vertex tree has n-1 edges Algorithms for checking connectivity
9
Checking by inspection
10
What about large graphs? s t Are s and t connected?
11
Brute-force algorithm? List all possible vertex sequences between s and t Check if any is a path between s and t n n such sequences
12
Algorithm motivation all
13
Distance between u and v Length of the shortest length path between u and v Distance between RM and BO? 1
14
Questions?
15
Breadth First Search (BFS) Is s connected to t? Build layers of vertices connected to s 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 L j : all nodes at distance j from s
16
Exercise for you Prove that L j has all nodes at distance j from s
17
BFS Tree BFS naturally defines a tree rooted at s L j forms the jth “level” in the tree u in L j+1 is child of v in L j from which it was “discovered” 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 1 1 2 2 3 3 L0L0 L1L1 4 4 5 5 7 7 8 8 L2L2 6 6 L3L3 Add non- tree edges
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.