{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

set12_sol

# set12_sol - CS112 Spring 2011 Problem Set 12 Graphs...

This preview shows pages 1–2. Sign up to view the full content.

CS112 Spring 2011: Problem Set 12 Graphs: Traversals/Toplogical Sorting ------------------------------------------------------------------------ 1. Consider this graph: This graph has /n+2/ vertices and 2/n/ edges. For every vertex labeled /i/, /1 <= i <= n/, there is an edge from /S/ to /i/, and an edge from /i/ to /T/. 1. How many different depth-first search sequences are possible if the start vertex is /S/? 2. How many different breadth-first search sequences are possible if the start vertex is /S/? *SOLUTION* 1. /n!/, for the different permutations of the vertices 1 through n. (Note: If a vertex v in this set is visited immediately after S, then T would be immediately visited after v.) For instance, say /n = 3/. Here are all possible DFS sequences (3! = 6): S 1 T 2 3 S 1 T 3 2 S 2 T 1 3 S 2 T 3 1 S 3 T 1 2 S 3 T 2 1 2. /n!/, similar to DFS. The only difference is that T will be the last vertex to be visited. So, if /n = 3/, the possible BFS sequences are: S 1 2 3 T S 1 3 2 T S 2 1 3 T

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

set12_sol - CS112 Spring 2011 Problem Set 12 Graphs...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online