{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

chapter3

# chapter3 - Chapter 3 Solutions 2 3.1 The figure below gives...

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

Chapter 3 – Solutions

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

View Full Document
2 3.1 The figure below gives the pre and post numbers of the vertices in parentheses. The tree and back edges are marked as indicated. A B C D E F G H I (1,12) (2,11) (3,10) (4,9) (7,8) (15,16) (14,17) (13,18) (5,6) Tree Edge Back Edge 3.2 The figure below shows pre and post numbers for the vertices in parentheses. Different edges are marked as indicated. A B C D E F G H (1,16) (2,11) (4,5) (7,8) (3,10) (13,16) (12,15) (6,9) Tree Edge Cross Edge Back Edge Forward Edge A B C D E F G H (1,16) (2,15) (3,14) (4,13) (5,12) (6,11) (7,10) (8,9) (a) (b) 3.3 (a) The figure below shows the pre and post times in parentheses. (1,14) (15,16) (2,13) (3,10) (11,12) (4,9) (5,6) (7,8) A B C D E F G H (b) The vertices A, B are sources and G, H are sinks. (c) Since the algorithm outputs vertices in decreasing order of post numbers, the ordering given is B, A, C, E, D, F, H, G . (d) Any ordering of the graph must be of the form { A, B } , C, { D, E } , F, { G, H } , where { A, B } indi- cates A and B may be in any order within these two places. Hence the total number of orderings is 2 3 = 8. 3.4 (i) The strongly connected component found first is { C, D, F, G, H, I, J } followed by { A, B, E } . { C, D, F, G, H, I, J } is a source SCC, while { A, B, E } is a sink SCC. The metagraph is shown in the figure below. It is easy to see that adding 1 edge from any vertex in the sink SCC to a vertex in the source SCC makes the graph strongly connected. (ii) The strongly connected components are found in the order { D, F, G, H, I } , { C } , { A, B, E } . { A, B, E } is a source SCC, while { D, F, G, H, I } is a sink. Also, in this case adding one edge from any vertex in the sink SCC to any vertex in the source SCC makes the metagraph strongly connected and hence the given graph also becomes strongly connected.
3 A,B,E C,D,F,G, H,I,J A,B,E D,F,G, H,I C 3.5 Create a new (empty) adjacency list for the reverse. We go through the list of G and if in the neighborhood of u , we find the vertex v , add u in the list of v in G R as the first element in the list. Note that it would have been difficult to insert u at the end of the list, but insertion in the first position takes only O (1) time. 3.6 (a) Note that each edge ( u, v ) contributes 1 to d ( u ) and 1 to d ( v ). Hence, each edge contributes exactly 2 to the sum v V d ( v ), which gives v V d ( v ) = 2 | E | . (b) Let V o be the set of vertices with odd degree and V e be the set of vertices with even degree. Then v V o d ( v ) + v V e d ( v ) = 2 | E | = v V o d ( v ) = 2 | E | - v V e d ( v ) The RHS of this equation is even and the LHS is a sum of odd numbers. A sum of odd numbers can be even, only if it is the sum of an even number of odd numbers . Hence, the number of vertices in V o (equal to the number of people with odd number of handshakes) must be even. (c) No. The following graph provides a counter-example as only one vertex ( B ) has odd indegree. A B 3.7 (a) Let us identify the sets V 1 and V 2 with the colors red and blue. We perform a DFS on the graph and color alternate levels of the DFS tree as red and blue (clearly they must have different colors). Then the graph is bipartite iff there is no monochromatic edge. This can be checked during DFS itself as such an edge must be a back-edge, since tree edges are never monochromatic by construction and DFS on undirected graphs produces only tree and back edges.

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 / 10

chapter3 - Chapter 3 Solutions 2 3.1 The figure below gives...

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

View Full Document
Ask a homework question - tutors are online