- Answer the problems on the exam pages.
- There are four problems, each with multiple parts, for 100 total points plus 10 extra credit. Actual scale was A = 93, C = 63.
- Some useful definitions precede the questions below.
- No books, notes, calculators, or collaboration.
- In case of a numerical answer, an arithmetic expression like
"2
^{17}- 4" need not be reduced to a single integer.

Q1: 20+10 points Q2: 30 points Q3: 30 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 numbers** are a sequence of naturals defined
by the rules F(0) = 0, F(1) = 1, and, for all n with n ≥ 1, F(n+1) =
F(n) + F(n-1).

For every natural n, we define two graphs, a directed graph
D_{n} and an undirected graph U_{n}. Each has vertex
set
{0, 1,..., n}. The directed edges of D_{n} are (1) (i, i+1)
for every i with 0 ≤ i ≤ n-1, (2) (i+2, i) for every *even*
i with 0 ≤ i ≤ n-2, and (3) (i, i+2) for every *odd* with 1
≤ i ≤ n-2.

We also view D_{n} as a labeled graph where each edge of
type (1) above has cost 2, and the other edges have cost 3.

The undirected graph U_{n} has the same vertex set as
D_{n}, and an undirected edge whenever D_{n} has a
directed edge. We will not have occasion to use edge costs in U_{n}.

```
Directed graph D_5 with edge costs. The graph U_5 has the
same nodes and edges but all the edges are undirected.
___________ _____________
/ 3 \ / 3 \
V \ V \
(0) ----> (1) ----> (2) ----> (3) ----> (4) ----> (5)
2 \ 2 2 ^ \ 2 2 ^
\______________/ \_____________ /
3 3
```

**Question 1 (20+10):**Pig Floyd is weighed at the beginning of every month. Let W(n), a real number, be his wieight in kilograms for month n. We will assume that for all n with n ≥ 1, his weight follows the rule W(n+1) = √2W(n) - W(n-1) + 700 - 350√2. Note that in our calculations we will not approximate √2. So if W(0) = 350 and W(1) = 400, for example, we calculate W(2) as 400√2 - 350 + 700 - 350√2 = 350 + 50√2.- (a, 5) Assume for this part only that W(0) and W(1) are both 350. Prove by (strong) induction on all naturals n that W(n) = 350.
- (b, 5) Now assume, for the rest of the problem, that W(0) = 350 and W(1) = 400. Calculate W(n) for all naturals n with n ≤ 10. Put your answers in the form a + b√2 where a and b are integers.
- (c, 10) Still assuming that W(0) = 350 and W(1) = 400,
prove by (strong) induction on all naturals n that each value W(n)
can be written in the form a
_{n}+ b_{n}√2, where a_{n}and b_{n}are*integers*depending on n. (You are not asked in this part to determine the integers a_{n}and b_{n}, only to prove that they exist. - (d, 10XC) Still assuming that W(0) = 350 and W(1) = 400, determine the value of W(84), which is Floyd's weight seven years after the weighings start. Justify your answer. You will probably find an induction proof useful to avoid having to calculate all the intermediate values of W(n).

**Question 2 (20):**The graph families U_{n}and D_{n}, for all naturals n, are defined above.- (a, 10) Prove by (strong) induction on n that in the graph
U
_{n}there are exactly F(n+1) different paths from vertex 0 to vertex n such that the vertex number always increases along the path. (Here F(n) refers to the Fibonacci sequence defined above.) - (b, 10) Given the cost function on D
_{n}given above, where edges of the form (i, i+1) have cost 2 and the others have cost 3, prove the following by (strong) induction for all*positive*naturals n: "The minimum-cost path in D_{n}from vertex 0 to vertex n has cost (3n+1)/2 if n is odd and has cost 3n/2 + 1 if n is even."

**Question 3 (30):**This question involves various searches of the graphs D_{5}and U_{5}defined and pictured above. Note that each of these graphs has six vertices and nine edges. In each case, assume that your search uses a closed list.- (a, 5) Conduct a breadth-first search of the undirected
graph U
_{5}, with start node 3 and no goal node. Draw the resulting BFS tree, indicating with edges are tree edges and which are non-tree edges. If two nodes enter the queue at the same time, they should come off in numerical order, lowest number first. - (b, 10) Conduct a depth-first search of the graph
D
_{5}, with start node 3 and no goal node. Draw the resulting DFS tree, indicating which edges are tree, back, forward, and cross edges respectively. If two nodes enter the stack at the same time, they should come off in numerical order, lowest number first. - (c, 10) Conduct a uniform-cost search of the directed graph
D
_{5}using the given edge costs, with start node 3 and only goal node 1. Indicate the order in which nodes enter and leave the priority queue. - (d, 5) Conduct an A
^{*}search of the directed graph D_{5}using the given edge costs, with start node 3 and only goal node 1. The heuristic function h for each node x should give h(x) = |x - 1|. (You may assume without proof that this heuristic is admissible and consistent.) Indicate the order in which nodes enter and leave the priority queue, and the priority assigned to each entry in that queue.

- (a, 10) Prove by (strong) induction on n that in the graph
U
**Question 4 (30):**The following are fifteen true/false questions, with no explanation needed or wanted, no partial credit for wrong answers, and no penalty for guessing. Some of them refer to the scenarios of the other problems, and/or the entities defined above. Each one counts two points.- (a) In the scenario of Question 1, whenever W(0) = W(1), we can be sure that W(0) = W(n) for all naturals n.
- (b) If f(0) = 4 and f(n+1) = f(n) + n - 3 for every natural
n, then f(n) = (n
^{2}- 5n + 8)/2 for every natural n. - (c) The set {0, 1, 2, 3, 4, 5, 6}, with the successor function S(i) = (i+1)%7, does not satisfy the fifth Peano axiom for naturals.
- (d) The operation of exponentiation on naturals, with E(x,
y) = x
^{y}, is neither commutative nor associative. - (e) If a binary string has odd length and has a first letter and a last letter that are different, it must contain either 00 or 11 as a substring.
- (f) The graph D
_{n}is strongly connected if and only if n is even. - (g) The graph U
_{n}is bipartite if and only if n ≤ 1. - (h) Let Σ be a nonempty finite alphabet with k
letters. Then the number of strings in Σ
^{n}that never have the same letter twice in a row is (k-1)k^{n-1}. - (i) A rooted binary tree has a number of leaves equal to its number of internal nodes.
- (j) A generic search may fail to terminate even if the search space is finite.
- (k) In part (d) of Problem 3, the heuristic h(x) = 2|x-1|
would
*not*have been both admissible and consistent. (It would fail to meet at least one of the conditions.) - (l) The call tree of our recursive
`factorial`

method has n-1 leaves for any input n with n > 1. - (m) There exists a boolean expression (as in Discussion #7) with more operators than primitive expressions.
- (n) Suppose that the first player has two choices for a first move in a finite game, and the optimal move is to choose the left subtree. Then every leaf value in the left subtree must be greater than or equal to every leaf value in the right subtree.
- (o) If a finite game has value v, then v must occur as a leaf value in its game tree.

Last modified 25 November 2017