Exam text is in black, solutions in blue.
Q1: 10+10 points Q2: 20 points Q3: 40 points Q4: 30 points Total: 100+10 points
Here are definitions of some terms, sets, predicates, and statements used on this exam.
Remember that a natural is a non-negative integer, so that the set N or all naturals is {0, 1, 2, 3,...}.
The Fibonacci function is recursively defined by the rules F(0) = 1, F(1) = 1, and (for all n > 0) F(n+1) = F(n) + F(n-1).
Let E(n) be recursively defined by the rules E(0) = 0, E(n+1) = 3E(n) + 6 for even n, and E(n+1) = 2E(n) + 3 for odd n.
Let V(n) be recursively defined by the rules V(0) = 1, V(n+1) = 3V(n) + 1 for odd n, and V(n+1) = 2V(n) + 1 for even n.
The set S of strings over the alphabet {a, b, c} is defined as follows:
There are exactly ten strings in S with length ≤ 2: λ, a, b, c, ab, ac, ba, bc, ca, and cb.
For any natural n, we define an undirected graph Gn whose nodes are labeled by the strings in S of length ≤ n. If w is a string in S, x and y are letters, wx and wy are both in S, and |wx| = |wy| ≤ n, then there are edges (w, wx), (w, wy), and (wx, wy) in G.
Equivalently, we can define the graphs Gn inductively as follows.
Undirected graphs G_0, G_1, and G_2, G_3. "L" means "lambda".
Numbers 1 or 2 within edges are edge weights for Question 3 (c) and (d).
In G_2, the edge (a, c, 1) is drawn crossing (b, ba, 2) and (b, bc, 2).
G_0 L G_1 L G_2 L
/|\ /|\
/ | \ / | \
2 2 2 2 2 2
/ | \ / | \
/ | \ / | \
a--1--b--1--c a--1--b--1--c
\ / /|\ / \ /|\
\---1---/ / | --/-1-\-- | \
2 2 2 2 2 2
/ | | | | \
/ | | | | \
ab-1--ac ba-1-bc ca--1-cb
G2 is a graph with ten nodes and fifteen edges.
The alphabetical order on strings is defined as follows:
First base case: For n = 0, 0 is divisible by 3 and F(n) = 0 is even.
Second base case: For n = 1, 1 is not divisible by 3 and F(1) = 1 is odd.
Strong inductive case: Assume that for all k with k ≤ n, F(k) is even if and only if k is divisible by 3. We must show that F(n+1) is even if and only if n+1 is divisible by 3. If n+1 is divisible by 3, neither n nor n-1 is, and by the SIH, both F(n) and F(n-1) are odd. F(n+1) is their sum, so it is even as it should be. If n+1 is not divisble by 3, then one of n or n+1 is divisible by 3 and one is not. So by the SIH, one of F(n) and F(n-1) is odd and the other even, making their sum F(n+1) odd, as it should be.
Comments: I gave four points for the base case, but to get those points you needed the two base cases for strong induction, and you had to say exactly what facts about n = 0 and n = 1 you need for the base case. For the inductive case, you needed to deal both with the case where n+1 is divisble by 3 and the case (or two cases) where it is not. Many people correctly computed from the definition that F(n+3) = 3F(n) + 2F(n-1), so that F(n+3) is guaranteed to be even if F(n) is. This can be the inductive step of a proof that for every n divisible by 3, F(n) is even. But in order to solve this entire problem with this fact, you need to also note that F(n+3) is odd if F(n) is odd, so that P(n) → P(n+3) holds in both the odd and even cases. If you do this, you need three base cases for n = 0, 1, and 2, because the inductive case only starts being useful to prove P(3).
The theorem is "∀n: F(n) is divisible by 8 if and only if n is divisible by 6:. I gave three points for a statement of this, but only two points if your statement was not an "if and only if" statement because you were asked "for exactly which values" the fact holds.
The appropriate base cases depend on how the induction works. There are two main approches:
First Proof: By repeated use of the Fibonacci definition, you can prove that F(n+6) = 8F(n+1) + 5F(n). If we know that F(n) is divisible by 8, this equation proves that F(n+6) is also divisible by 8. Thus if we prove a base case of n = 0, by observing that F(0) = 0 is divisible by 8, we can prove half the theorem by using induction on all n that are divisible by 6, to prove that they all have F(n) divisible by 8. But we can also use this same equation to prove that if F(n) is not divisible by 8, then neither is F(n+6). This is because F(n+6) is congruent modulo 8 to 5F(n), and 5 has an inverse modulo 8 as it is relative prime to it. Using this, we can carry out a proof of the entire theorem, using six separate base cases for n = 0 through n = 5 and observing the F(1), F(2),..., F(5) are not divisible by 8.
Second Proof: We can augment our statement P(n) to say exactly what F(n) % 8 is for every possible value of n % 12. We have to view n modulo 12 because the sequence of values of F(n) % 8 has a period of 12: it is 0, 1, 1, 2, 3, 5, 0, 5, 5, 2, 7, 1, 0, 1, 1, 2,... and so on. So our P(n) gives a conditional statement about F(n) with twelve cases: "F(n) % 8 is 0 if n % 12 = 0, is 1 if n % 12 = 1, is 1 if n % 12 = 2,..." and so forth. We can then do a strong induction for this new P(n), with just two base cases for n = 0 and n = 1 (more base cases don't hurt) and an inductive step that breaks into twelve cases. The first case would be "Suppose that (n + 1) % 12 = 0. Then n % 12 = 11 and (n - 1) % 12 = 10, so by the SIH we know that F(n) % 8 = 1 and F(n - 1) % 8 = 7. By the Fibonacci definition, F(n + 1) % 8 = 0 and P(n + 1) is true in this case." The other eleven cases are similar. (I didn't insist that you spelled them all out if you indicated how they would go.)
I gave six points for a complete proof of "(n % 6 = 0) → (F(n) % 8 = 0)".
For the base case, we must check that the claimed formula matches the definition for n = 0, which it does because 3×60 - 3 = 0. We only need one base case because this is an ordinary induction, but that base case must be 0 because we are asked to prove the statement "for any natural".
For the inductive step, we assume that E(2n) = 3×6n - 3, and use the formulas to evaluate E(2n+2). Since 2n+1 is odd, E(2n+2) = 2E(2n+1) + 3, and because 2n is even, E(2n+1) = 3E(2n) + 6, so E(2n+2) = 2(3E(2n) + 6) + 3 = 6E(2n) + 15. By the IH, this is 6(3(6n - 3) + 15 = 3×6n+1 - 18 + 15 = 3×6n+1 - 3 as desired.
I gave four points for a correct base case, but only one more if you attempted to use the formula to go directly from E(2n+2) to E(2n), because the formula only relates the E values for two consecutive integers and you have to use it twice to relate E(2n+2) to E(2n). The definition depends on the parity of the argument of E on the right-hand side, not that on the left-hand side -- look at what value fits into the role of "n" in the definition. (It doesn't matter whether n itself is even or odd.) As it turns out, in this case if you get the two formulas backward and compute 3(2E(2n) + 6) + 3, you also get 6E(2n) + 15 and can complete the induction, but if you did this I took off two points for the error in interpreting the formulas.
This is very similar to part (a). For the base case, we must verify that the value of V(0) given by the claimed formula matches the definition, which it does because (9×60 - 4)/5 = 5/5 = 1 and V(0) is defined to be 1. For the inductive case, we assume that V(2n) is as claimed and compute V(2n+2) as 3V(2n+1) + 1 (because 2n+1 is odd) = 3(2V(2n) + 1) + 1 (because 2n is even) = 6V(2n) + 4. Using the IH, we get that V(2n+2) = 6((9×6n - 4)/5 + 4 = (9×6n+1 - 24)/5 + 20/5 = (9×6n+1 - 4)/5 as desired.
Again I gave four points for a correct base case and only one more for an argument that tried to use the formula to go directly from V(2n) to V(2n+2). This time if you got the two formulas backwards, you got V(2n+2) = 6V(2n) + 3 insteaad of 6V(2n) + 4, and the arithmetic should not work. I took off two points for an error plus an additional point if you fudged the arithmetic to make it work anyway.
The tree has root λ with only child a. Node a has two children, ab and b. Node ab has only child ac. Node b has two children, ba and c. Node ba has only child bc. Node c has only child ca which has only child cb. These are the nine tree edges -- the other six edges (corresponding to the six discards in the search) are (λ, b), (λ, c), (a, ac), (a, c), (b, bc) and (c, cb). These are back edges in the tree since they are discovered from the descendent and go to the ancestor, as do all non-tree edges in a DFS tree of an undirected graph.
To draw the tree, when placing a node on the queue, we'll indicate the neighbor from which it was visited; when first taken off the queue, that neighbor will be the parent in the tree. Taking a node off the second time results in a non-tree edge.
The tree has five children of a at level 1, with four non-tree edges at that level: between ab and ac, and between λ, b and c. Node b has two children at level 2, ba and bc, with a non-tree edge between them, and c has two children, ca and cb, linked by a non-tree edge.
We compute the heuristic function for all nodes in the graph. h = 0 for bc. h = 1 for b and ba. h = 2 for λ, a, c. h = 3 for the remaining nodes: ab, ac, ca, cb.
FALSE. The value of f for every odd number is defined directly, and for any even number the recursion will continue until an odd number is reached. For example, f(12) = 1 + f(6) = 2 + f(3) = 2 + 10 = 12. This is somewhat similar to the definition of the Collatz sequence, the subject of a famous unsolved problem which you may look up on your own if you are interested.
TRUE. This is the repeated squaring algorithm for computing powers -- we could prove the claim by induction on n, letting x be arbitrary.
FALSE. P(1) does not follow from the given statements. We could let P(n) be "n ≠ 1" and the premises would all be true, but the conclusion false.
TRUE. These rules define G to be the "greater than" predicate. We could prove the claim by induction on z, letting x and y be arbitrary and using only the second statement of the definition.
FALSE. These premises are enough to prove P(w) for all strings w, not just those in S.
FALSE. Every node has a path of at most n-1 edges to a node on the first level (a, b, or c) and these nodes all have edges to one another. So any two nodes have a path between them of at most (n-1) + (n-1) + 1 = 2n - 1 edges.
FALSE. If u and v are both "a", they are both in S but "aa" isn't.
TRUE. A string is in S if and only if it not of the form uaav, ubbv, or uccv where u is a string of even length. IF we concatenate two strings x and y each of even length, a double letter in in a bad position in x or y if and only if it is in a bad position in xy.
TRUE. Let G be the complete graph. Any of the n! orderings of the n nodes leads to two distinct simple paths that are not cycles, one with n-1 edges and one of n-2 edges. For example, with n = 4 we can assign the ordering a-b-c-d to the path a-b-c-d and the path a-b-c (leaving out d). Neither of these are cycles because they do not begin and end at the same point. We should be a bit careful of the n = 2 case: there the four (2(2!)) paths are a-b, b-a, a, and b. The latter two are simple paths (since they don't reuse a vertex) and are not cycles because a cycle in an undirected graph must have at least three edges.
TRUE. If it were not connected and had no isolated nodes, the connected components could be size 2 and 4, or size 3 and 3. (A graph with more than two connected components has fewer edges than one with two components, and we'll show these have too few edges.) A graph with 2 and 4 nodes in its components could have at most seven edges, and one with 3 and 3 could have at most six.
FALSE. If x is a node in a directed graph with an asymmetric edge relation, and its component has more than one node, it must have an edge to another node y. Since y cannot have an edge back to x, there must be a least one other node in the component. So a graph with two such components must have at least six nodes.
TRUE. A prefix expression string must begin with an operator, so the only place to put the + is at the beginning.
TRUE. For n = 2, let the graph have one edge -- both trees have depth 1 which is fine because n = 1 = 1. For n = 3, let the graph be a triangle, so the DFS has depth 2 and the BFS has depth 1. For n > 3, let the graph be a cycle of n - 1 nodes together with a node v that shares an edge with every node of the cycle. (This is called a wheel graph and has 2n - 2 edges.) The BFS tree of the wheel clearly has depth 1 because every other node is distance 1 from v and thus goes on the first level. The DFS will have depth n - 1 because each node we encounter will have an unseen neighbor, until we have seen them all. (The DFS tree consists of a single path.)
FALSE. If this happened, there would be a directed path of length t + 1 from the start node to the second node (using the path to the first node and the alleged edge from the first to the second), but this node would be on level t + 2. The level in a BFS tree is the length of the shortest path from the start node.
FALSE. If we take any outcome that one player will avoid, and make it worse, that player will still avoid it and the optimal play of the game will be exactly the same.
Last modified 21 November 2018