- Answer the problems on the exam pages.
- There are six problems (most with multiple parts) for 120 total points plus 10 extra credit. Actual scale was A = 105, C = 67.5.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
- Numerical answers may be given as expressions involving arithmetic operations (including exponentiation and factorial) or the functions P(n, k) and C(n, k). In general a summation is a complete answer to a counting problem, but a recurrence or a generating function is not.

Q1: 20 points Q2: 20+10 points Q3: 40 points Q4: 20 points Q5: 20 points Total: 120+10 points

Exam text is in black, solutions in blue.

The undirected graph G has node set {a, b, c, d, e, f| and the following set of nine edges:

{(a, b), (a, c), (b, c), (c, d), (c, e), (c, f), (d, e), (d, f), (e, f)}

**Question 1 (20):**Identify each of these statements as true or false. The first five deal with the graph H defined in Question 5. No explanation is needed or wanted, and there is no partial credit or penalty for guessing (2 points each).- (a) G is a planar graph and can be drawn in the plane
with five regions (counting the exterior region).
TRUE. Since there are six nodes and nine edges, Euler's Formula gives E - V + 2 = five regions. We can draw the graph by having a-b-c and c-d-e as triangles sharing the vertex c, then putting f in the middle of the c-d-e triangle connected to each of its vertices, giving five regions.

- (b) The graph G has no Euler path, and it is not possible to
add one edge to it to make an undirected graph with an Euler path.
TRUE. G has four vertices of odd degree and could only have an Euler path if it had zero or two. By adding an edge, we could change the parity of two of the vertices. But to give the graph an Euler path we would have to change two of the odd-degree vertices to even degree. This is impossible by adding an edge because all the possible edges among the odd-degree vertices already exist, and an undirected graph cannot have more than one edge with the same endpoints.

- (c) There does not exist a spanning tree of G in which
vertex c has degree 1.
TRUE. In a spanning tree, c must have simple paths to both a and d, for example, and these paths must leave c on different edges.

- (d) Let A be the adjacency matrix of G, viewed as an
integer matrix. Then the matrix I + A + A
^{2}has at least one zero entry.FALSE. The entry of this matrix in the (i, j) position gives exactly the total number of paths of length 0, 1, or 2 from vertex i to vertex j. Since no two vertices of G are more than two edges apart, this is always true.

- (e) The chromatic polynomial of G is divisible by
the linear polynomial r - 4.
FALSE. If this were true, substituting r = 4 into the chromatic polynomial would give 0. But this would also give the number of proper four-colorings of G, which is clearly positive because some proper four-colorings exist.

- (f) Let f(x) and g(x) be the exponential
generating functions for the sequences
{a
_{n}} and {b_{n}} respectively. Define the sequence {c_{n}} so that f(x)g(x) is the exponential generating function of {c_{n}}. Then for any r, c_{r}is the sum for k from 0 to r of C(r, k)a_{k}b_{r-k}.TRUE. The x

^{r}term of f(x)g(x) is the sum for k from 0 to r of the x^{k}term of f(x) times the x^{r-k}term of g(x). By the definition of f(x) and g(x), this is the sum for k from 0 to n of (a_{k}/k!) times (b_{n-k}/(r-k)!). To get c_{r}, we multiply this sum by r!, getting the sum for k from 0 to r of (r!/(k!(n-k)!)(a_{k}b_{r-k}, as desired. - (g) Every solution to the recurrence a
_{n}= 3a_{n-a}- 3a_{n-2}+ a_{n-3}is a polynomial in n.TRUE. The characteristic polynomial of this recurrence is (1-A)

^{3}, so that 1 is a root of muliplicity 3. By our general solution for linear recurrences, any solution is of the form (Xn^{2}+ Yn + Z)1^{n}, which is a polynomial in n. - (h) The rook polynomial of a 2 by 2 square is
1 + 4r + 2r
^{2}, and the number of permutations of {1, 2, 3, 4} that do not contain any of the pairs (2, 2), (2, 3), (3, 2), or (3, 3) is given by 1(0!) + 4(1!) + 2(2!) = 9.FALSE. The rook polynomial is correct, but the correct formula for those permutations is 1(4!) - 4(3!) + 2(2!) = 4, not 9. Any such permutation maps {1, 4} into {2, 3} and vice versa, offering two binary choices and thus four total choices.

- (i) Every one-stalk game of Red-Blue Hackenbush has a value
that is a "number" in Conway's terminology.
TRUE. Any move by Left or Right leads to another such game, which by by the inductive hypothesis has a number value. And every Left move leads to a game with smaller value than the game resulting from any Right move, as we could show by adding the two games and showing the result to be a win for Right. The base case of the induction is the empty stack, which is a zero game and by definition has a number value.

- (j) It is not the case that every one-stalk game of
Red-Blue Hackenbush has a value that is a real number.
TRUE. Every finite stalk has a value that is a dyadic integer, but infinite stacks can have values that are infinite, or that differ from a dyadic integer by an infinitesimal.

- (a) G is a planar graph and can be drawn in the plane
with five regions (counting the exterior region).
**Question 2 (20):**In this question we will determine the number of ways to color each vertex of G (the undirected graph defined above) black or white, where two colorings are considered tot be the same if there is an automorphism of G taking one to another. (Recall that an**automorphism**is a bijection of the vertices that takes edges to edges and non-edges to non-edges.) Note also that we are considering all two-colorings here, not just "proper colorings" as in the definition of chromatic number of the chromatic polynomial.- (a, 5) How many ways are there to color each vertex black or
white if we
*do not*consider the automorshisms? (This is a very easy question.)There are two possible colors for each of the six vertices, so 2

^{6}= 64 total colorings. - (b, 5) There are exacctly twelve automorphisms of G --
describe them and argue that there aren't any others.
Any automorphism must preserve the degrees of vertices. So vertex c, the only one with degree 5, must be fixed. Vertices a and b, with degree 2, may be either fixed or exchanged, and vertices d, e, and f, with degree 3, must be permuted among themselves.

This means that the only candidates for automorphisms are the twelve pairs (x, y) where x is a permutation of {a, b} and y is a permutation of {d, e, f}. In fact all twelve of these are easily seen to be automorphisms, since a and b have edges only to one another and to c, and d, e, and f also each have edges exactly to one another and to c.

- (c, 10) Determine the number of two-colorings of G up to
symmetry. One way to do this is to find and apply the
**cycle index polynomial**of the action of the automorphism group of G. (If you do this, keep in mind that if an automorphism fixes a vertex, it creates a cycle of size one.) It's also posible to determine the number of colorings by an*ad hoc*argument -- this is fine if your reasoning is clear.First the cycle index polynomial: For each of the twelve permutations we need to find the sizes of the orbits. The two permutations of {a, b} contribute two one-cycles and one two-cycle respectively, Since c is fixed, we always have a one-cycle from it. Of the six permutations of {d, e, f}, one gives three one-cycles, two give a three-cycle, and three give a two-cycle and a one-cycle. This makes the overall cycle index polynomial

(1/12)(x

_{1}^{6}+ 4x_{2}x_{1}^{4/sup> + 3x22x12 + 2x3x13 + 2x3x2x1). Note that as the action of the group on the set is the direct product of three actions on disjoint subsets, we could obtain this polynomial by multiplying together the three polynomials for the individual actions. }We find the number of two-colorings up to symmetry by substituting 2 for each of the variables x

_{i}, getting(1/12)(64 + 128 + 48 + 32 + 16) = 288/12 = 24.

The

*ad hoc*method I had in mind was to note that any coloring is characterized up to symmetry by the number of black vertices among {a, b} (0, 1, or 2), among {c} (0 or 1), and among {d, e, f} (0, 1, 2, or 3). And any combination of these numbers is possible, for a total of 3 times 2 times 4 = 24 total colorings. - (d, 10 XC) Determine the
**pattern inventory**of the colorings counted in part (c). This is a polynomial in b and w that tells how many of the colorings have each number of black and white vertices. This can be done easily from the cycle index polynomial, but there is also an*ad hoc*argument you could make if you explain it clearly. For full credit, your answer should be expressed as a sum of monomials.We can obtain this from the cycle index polynomial above by substituting b

^{i}+ w^{i}for each variable x_{i}. Using the factorization of the polynomial from the direct product decomposition, this becomes (b + w)(1/2)(b^{2}+ w^{2}+ (b+w)^{2}) (1/6)((b+w)^{3}+ 3(b+w)(b^{2}+ w^{2}) + 2(b^{3}+ w^{3})) = (b+w)(b^{2}+ bw + w^{2})(b^{3}+ b^{2}w + bw^{2}+ w^{3}) = b^{6}+ 3b^{5}w + 5b^{4}w^{2}+ 6b^{3}w^{3}+ 5b^{2}w^{4}+ 3bw^{5}+ w^{6}.The

*ad hoc*method looks at the 24 permutations found above and notes that there are one each all-black and all-white, three with one white (with the white vertex either among {a, b}, {c}, or {d, e, f}), five with two whites (three with the two whites in different sets, one with both a and b white, and one with two of {d, e, f} white), six with three whites (distributed 2-1-0, 2-0-1, 1-1-1, 1-0-2, 0-1-2, or 0-0-3), five with four whites, and three with five.

- (a, 5) How many ways are there to color each vertex black or
white if we
**Question 3 (40):**This problem concerns the**chromatic polynomial**of an undirected graph, which is a polynomial in r that gives the number of**proper colorings**of the vertices of the graph using r colors. (A proper coloring is one where no edge connects two vertices of the same color.)- (a, 10)
Determine the chromatic polynomial of G. You may use any
method, but explain your reasoning. (The general algorithm
given in Tucker may not be the fastest way to get the polynomial
for this particular graph.) You may find the results of parts
(c) and/or (d) useful.
An

*ad hoc*way to determine χ(G) is to color the vertices one by one. If we choose one of r colors for a, there are r-1 remaining colors for b, then r-2 remaining for c. Then there are r-1 for d (every color except c's), r-2 for e, and r-3 for f, giving a total of r(r-1)^{2}(r-2)^{2}(r-3) total choices.We could also reason that there are P(r, 3) ways to color a, b, and c by themselves, and P(n, 4) ways to color c, d, e, and f by themselves, using the result of part (c). Of these pairs of colorings, exactly a 1/r fraction have the same color for c and can thus be combined into a single proper coloring of all of G. The polynomial P(n, 3)P(n, 4)/r is exactly that calculated above.

To apply Tucker's method, we could look at the edge (a, b), letting G' be the graph obtained by deleting it from G and G'' be the graph obtained by merging its endpoints. Then χ(G) = χ(G') - χ(G''). Using the edge (a, c) simlarly, we find that χ(G'') = rχ(K

_{4/}) - χ(K_{4}) and that χ(G') = rχ(G'') - χ(G''). Since χ(K) = P(n, 4) by part (c), this gives us that χ(G'') = (r-1)P(n, 4), χ(G') = (r-1)^{2}P(n, 4), and finally χ(G) = P(n, r)((r-1)^{2}- (r-1)) = P(n, r)(r-1)(r-2), equalling the other results above. - (b, 10)
We stated in lecture that the
**3-colorability**problem, of deciding whether a given undirected graph has a proper coloring with three colors, is**NP-complete**. Assuming this fact, prove that if there is a polynomial-time algorithm that takes an undirected graph as input and computes its chromatic polynomial, then P = NP.If we could compute the chromatic polynomial of a graph in polynomial time, we could then substitute r = 3 into this polynomial and compute the number of proper 3-colorings. This number is positive if and only if the graph is 3-colorable. So we have a polynomial time algorithm for 3-colorability, implying P = NP, as long as the substitution and evaluation can be carried out itself in polynomial time. To prove that it can actually has some subtleties. In what form are we given the chromatic polynomial by the hypothesized algorithm? It's reasonable to say that it is as a sum of monomials. We know that the degree of the polynomial is no greater than n, the number of nodes in the graph. We can raise 3 to each power up to n, certainly, and then get the result of the evaluation as a sum of products, as long as the coefficients of the polynomial have a polynomial number of bits. This has to be so if the coefficients are the output of a pulynomial-time algorithm, as we are assuming, but we could also prove by induction on n that the chromatic polynomial of any n-vertex graph has coefficients bounded by 2

^{p(n)}for some polynomial p.That said, I gave full credit if you explained

*how*you would determine 3-colorability given the chromatic polynomial. It was not enough to just assert that you could, and it was certainly wrong to make assumptions about how the hypothesized algorithm got its results. - (c, 10) Let t
_{n}(r) be the chromatic polynomial of a tree with n nodes and let k_{n}(r) be the chromatic polynomial of the complete graph K_{n}. Find and justify two recurrences (each with a base case for n = 1) that compute t_{n}in terms of t_{n-1}(r) and k_{r}in terms of k_{n-1}(r). Solve these recurrences to get closed forms for t_{n}(r) and k_{n}(r). (A*consequence*of the correct argument here is that all n-node trees have the same chromatic polynomial.)Given any n-node tree, we can take one of its leaves (any tree has at least one leaf, in fact at least two), remove it, color the remaining tree in one of t

_{n-1}(r) ways, then color the leaf in one of r-1 ways. This proves that t_{n}(r) = (r-1)t_{n-1}(r), with base case t_{1}(r) = r because a single node may have any of the r colors. This is a linear recurrence that solves to t_{n}(r) = r(r-1)^{n-1}. Given a graph K_{n}, my solution was to color one of the nodes with one of the r colors, then color the rest of the graph using r-1 colors, giving a recurrence of k_{n}(r) = rk_{n-1}(r-1). Most of you followed the reasoning for trees above: remove a node, color the remaining graph with k_{n-1}(r) colors, then use one of the remaining r-n+1 colors for the removed node. This gives k_{n}(r) = (r-n+1)k_{n-1}(r). Either way we have a base case of k_{1}(r) = r. We might perhaps worry about the case where r < n and there are no colorings at all, as the reasoning behind the inductive step does not hold in this case. But each recurrence solves to K_{n}(r) = P(r, n), and P(r, n) always evaluates to zero if r < n. Our standard methods for solving recurrences do not work when the coefficient of the linear recurrence varies with n, so we really should do the easy induction proof to solve this recurrence. - (d, 10). In this part we will compute t
_{n}(r) in another way, using inclusion-exclusion. Consider an arbitrary n-node tree T. For each edge e of the tree, let C_{e}be the set of colorings that are*not*proper because the two endpoints of e have the same color. Determine the size of C_{e}and, for each k from 1 to the number of edges in T, determine the size of any intersection of any k of the C_{e}'s. (You should argue that all of the intersections for a given k have the same size.) Using inclusion-exclusion, determine the number of colorings of T that are proper,*i.e.*, that are*not*members of the union of the C_{e}'s. Argue that this number is the same polynomial that you computed in part (c).The number of colorings in C

_{e}is r^{n-1}, because once we have colored the two endpoints of e with one color, we choose a separate color for each of the other n-1 vertices. If we have a set of k edges among the n vertices, we know that they form an undirected graph with exactly n-k connected components. A coloring of the vertices that is improper among all k edges must use a single color for each connected component, so there are exactly r^{n-k}such colorings.By inclusion-exclusion, the number of proper colorings is the number of all colorings, r

^{n}, minus the size of each C_{e}, plus the sum of the sizes of each intersection of two C_{e}'s, plus the sizes of three-way intersections, and so forth. This is the sum for k from 0 to n-1 of (-1)^{k}C(n-1, k)r^{n-k}, which by the Binomial Theorem is exactly the r(r-1)^{n-1}calculated above.

- (a, 10)
Determine the chromatic polynomial of G. You may use any
method, but explain your reasoning. (The general algorithm
given in Tucker may not be the fastest way to get the polynomial
for this particular graph.) You may find the results of parts
(c) and/or (d) useful.
**Question 4 (20):**In this problem we will yet again distribute r identical treats to three distinguished dogs, this time Cardie, Duncan, and Guinness. Our goal will be to find a generating function for the number s_{n}of distributions in which Cardie gets strictly more treats than Duncan, Cardie gets strictly more than Guinness, and each dog gets at least one treat.- (a, 5) Find the explicit values of s
_{7}and s_{8}, by any method. (Listing the solutions without justification is fine if you are correct.)With seven treats, Cardie can get at most five because Duncan and Guinness need one each. 5-1-1 is the only way she can get exactly five. If she gets four, we could have 4-1-2 or 4-2-1. If she gets three, we must have 3-2-2 in order that Cardie gets the most. And she cannot get fewer than 7/3 and have the most. So we have a total of four possible distributions.

With eight treats, by similar reasoning, the possible distributions are 6-1-1, 5-1-2. 5-2-1, 4-1-3, 4-2-2, and 4-3-1. If Cardie gets only three, dividing the remaining five would cause one of the other two dogs to tie or exceed Cardie's treats. There are six total distributions meeting the conditions.

- (b, 10) We also define t
_{r}to be the total number of distibutions of r treats to the three dogs, with only the condition that each dog gets at least one treat. We define u_{r}to be the number where each dog gets at least one treat, and Cardie and Duncan tie for the largest number of treats (possibly as part of a three-way tie), and v_{r}to be the number where all three dogs get the same (positive) number of treats. Determine generating functions for t_{r}, u_{r}, and v_{r}, each as ratios of polynomials.The generating function to give one or more treats to a single dog is x/(1-x), or equivalently 1/(1-x) - 1, and so the generating function for t is just the cube of this polynomial. Similarly, the number of ways to give an equal positive number of treats to each dog has a generating function of x

^{3}3), or equivalently 1/(1-x^{3}) = 1.If Cardie and Duncan tie for the most treats, then Guinness gets some positive number g and the other two eachget some non-negative number a in addition to g. The total number of treats awarded is then g+a for Cardie and Duncan, and g for Guinness, or 3g + 2a in all. The generating function for u is thus x

^{3}/(1-x^{3}) times 1/(1-x^{2}). - (c, 5) Use Inclusion/Exclusion to express the
generating function for s
_{r}in terms of those for t_{r}, u_{r}, and v_{r}, and thus compute the generating function of s_{r}as a ratio of polynomials. You need not simplify. (Hint: Cardie gets strictly the most treats in exactly one-third of the distributions in which there is no tie for the most treats.)There are three ways that a distribution could be counted by t

*without*having a single dog getting more treats than the other two -- Cardie and Duncan could tie for the lead, Cardie and Guinness could tie, or Duncan and Guinness could tie. Each of these scenarios occurs in u_{r}ways with r total treats.To count the single-lead distibutions, we take t

_{r}, subtract the three copies of u_{r}, and then correct for overcounting by inclusion-exclusion. But to do this is subtle and hardly anyone got it right. We add back in for the three ways in which*two*of the tied-lead conditions apply, and then subtract for the one way in which*all three*apply. But two of the conditions cannot apply without the third applying as well, so each of these number of ways is just v_{r}. Thus from our t_{r}- 3u_{r}, we add in three copies of v_{r}and then take one away, for a total of t_{r}- 3u_{r}+ 2v_{r}. This counts all the distribution with no tie for the most treats, and s_{r}is exactly one-third of this.I did a calculation which came out as (x

^{4}+ x^{6})/(1-x)(1-x^{2})(1-x^{3}), which actually can be interpreted combinatorially. Let's call this (x^{4}+ x^{6})/d(x). 1/d(x) is the generating function for the number of ways to give a treats to each dog, then b to Cardie and Duncan, then c to Cardie, where a, b, and c are all non-negative. If we give three to Cardie, two to Duncan, and one to Guinness before doing this, we get the number of ways to give Cardie strictly more than Duncan and Duncan strictly more than Guinness, and the generating function for this is x^{6}/d(x). We can interpret x^{4}/d(x) as the number of ways to give two to Cardie, one each to Duncan and Guinness, and then a, b, and c as before. So we have counted every distribution with C > D = G once and every distibution with C > D > G twice. If we reinterpret one copy of the latter as the number of ways to have C > G > D, we have counted all the distributions where Cardie gets strictly more than each of the others.

- (a, 5) Find the explicit values of s
**Question 5 (20):**In this problem we have a two-player game played with a single chess king on an eight-by-eight chessboard. We will call the top left (northwest) square (0, 0), the top right (northeast) square (0, 7), the southwwst square (7, 0), and the southeast square (7, 7). The king starts on (7, 7) and the game ends when one player wins by moving it to (0, 0). On each turn a player may move the king one square north, west, or northwest. (A chess king could normally move one square in any of the eight directions, but we disallow this.)- (a, 10) Recall that the
**kernel**of such a game is the set of positions from which the second player wins under optimal play. (Thus (0, 0) is in the kernel, since if the game starts there the first player has no more and immediately loses.) Determine the kernel of this game and hence which player (first or second) wins from each possible starting position.Clearly (0, 0) is in the kernel and (0, 1), (1, 0), and (1, 1) are not, because they have direct moves to (0, 0). We can then see that (0, 2), (2, 0), and (2, 2) have moves only to non-kernel positions and must be in the kernel. In this way we can see that the kernal positions are exactly (x, y) where both x and y are even. To prove this, we observe that no move from an even-even position goes to another even-even position, and that every other position has a move to an even-even position. Thus from (7, 7), the first player has a winning move to (6, 6) because this position is in the kernel.

- (b, 10) Recall that the
**Grundy number**of a position in such a game is the size of a one-pile Nim game that is**equal**(in Conway's terminology) to the game starting at that position. Find the Grundy number of (7, 7) in this game. (This will probably involve finding the Grundy numbers of most or all of the other positions.)We can compute the Grundy number of a position (x, y) once we know the numbers of every position we can move to from (x, y) -- it is the smallest natural number that one cannot move to from (x, y) . The 0 row at the top thus has Grundy numbers 0, 1, 0, 1, 0, 1, 0, 1. The 1 row has 1, 2, 3, 2, 3, 2, 3, 2, 3. The 2 row has 0, 3, 0, 1, 0, 1, 0, 1. The 3 row has 1, 2, 1, 2, 3, 2, 3, 2. The 4 row has 0, 3, 0, 3, 0, 1, 0, 1. The 5 row has 1, 2, 1, 2, 1, 2, 3, 2. The 6 row has 0, 3, 0, 3, 0, 3, 0, 3 and the 7 row has 1, 2, 1, 2, 1, 2, 1, 2. Thus the number of (7, 7) is 2.

- (a, 10) Recall that the

Last modified 6 January 2019