------------------------------------------------------------------------------ Mohamed G. Gouda CS 311 Fall 2015 Midterm 2 ------------------------------------------------------------------------------ 1. (5 points) Let G1 and G2 be two graphs that have the same number of vertices (5) and the same number of edges. The degrees of all vertices in G1 are 1, 2, 2, 3, 4. The degrees of all vertices in G2 are x, 1, 2, 3, 3. What is the value of x. Explain your answer. 2. (5 points) Let G be a bipartite graph. What are the possible values of the chromatic number of G. Explain your answer. 3. (5 points) What is the chromatic number of the following graph G=(V, E) where V = {1, 2, 3, 4, 5, 6} E = {(1,2), (1,4), (2,3), (2,4), (2,5), (3,5), (4,5), (4,6), (5,6)} Explain your answer. 4. (5 points) Verify that the following program specification holds: (T) x:=(y+1) (x > y) ------------------------------------------------------------------------------- Solution ------------------------------------------------------------------------------- 1. From Handshake Theorem, the number of edges in G1 is (1+2+2+3+4)/2 = 6. Thus the number of edges in G2 is also 6. From Hamdshake Theorem, (x+1+2+3+3) = 2*6 = 12. Thus x = 3. ------------------------------------------------------------------------------- 2. If G has no edges, then the chromatic number of G is 1, else the chromatic number of G is 2. Explanation: Because G is bipartite, then from the Bipartite Graph Theorem, then G can be colored using 2 colors. Then the chromatic number of G is either 1 or 2. If G has no edges, then G can be colored using 1 color and the chromatic number of G is 1. Otherwise, G can't be colored using 1 color and the chromatic number of G is 2. -------------------------------------------------------------------------------- 3. Chromatic number of G is 3. First G can be colored using 3 colors as follows: color(1) = Green, color(2) = Red, color(3) = Blue, color(4) = Blue, color(5) = Green, color(6) = Red Second G can't be colored using 2 colors because the three vertices 1, 2, 4 need to be colored distinict colors. -------------------------------------------------------------------------------- 4. In order to verify that the following program specification holds: (T) x:=(y+1) (x>y) we need to prove the predicate: (All x, y, (T) => (y+1)>y) as follows: T => {((y+1) > y) is clearly true} (y+1) > y ------------------------------------------------------------------------------ Mohamed G. Gouda CS 311 Fall 2015 Midterm 2 ------------------------------------------------------------------------------ 1. (5 points) Let G1 and G2 be two graphs that have the same number of vertices (5) and the same number of edges. The degrees of all vertices in G1 are 1, 2, 3, 3, 3. The degrees of all vertices in G2 are 1, 2, x, 3, 4. What is the value of x. Explain your answer. 2. (5 points) Let G be a bipartite graph. What are the possible values of the chromatic number of G. Explain your answer. 3. (5 points) What is the chromatic number of the following graph G=(V, E) where V = {1, 2, 3, 4, 5, 6} E = {(1,2), (1,3), (2,3), (2,4), (2,5), (3,5), (3,6), (4,5), (5,6)} Explain your answer. 4. (5 points) Verify that the following program specification holds: (T) x:=(y+1) (x > y) ------------------------------------------------------------------------------ Solution ------------------------------------------------------------------------------- 1. From Handshake Theorem, the number of edges in G1 is (1+2+3+3+3)/2 = 6. Thus the number of edges in G2 is also 6. From Hamdshake Theorem, (x+1+2+3+4) = 2*6 = 12. Thus x = 2. ------------------------------------------------------------------------------- 2. If G has no edges, then the chromatic number of G is 1, else the chromatic number of G is 2. Explanation: Because G is bipartite, then from the Bipartite Graph Theorem, then G can be colored using 2 colors. Then the chromatic number of G is either 1 or 2. If G has no edges, then G can be colored using 1 color and the chromatic number of G is 1. Otherwise, G can't be colored using 1 color and the chromatic number of G is 2. -------------------------------------------------------------------------------- 3. Chromatic number of G is 3. First G can be colored using 3 colors as follows: color(1) = Red, color(2) = Blue, color(3) = Green, color(4) = Green, color(5) = Red, color(6) = Blue Second G can't be colored using 2 colors because the three vertices 1, 2, 3 need to be colored distinict colors. -------------------------------------------------------------------------------- 4. In order to verify that the following program specification holds: (T) x:=(y+1) (x>y) we need to prove the predicate: (All x, y, (T) => (y+1)>y) as follows: T => {((y+1) > y) is clearly true} (y+1) > y ---------------------------------------------------------------------------------