- Answer the problems on the exam pages.
- There are five problems, each with multiple parts, for 100 total points plus 10 extra credit. Actual scale A = 90, C = 62.
- 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 points Q2: 15 points Q3: 25 points Q4: 20+10 points Q5: 20 points Total: 100+10 points

Here are definitions of sets, predicates, and statements used in Questions 1-5 on this exam.

Remember that a **natural** is a non-negative integer, so that
the set **N** of all naturals is {0, 1, 2, 3,...}.

Questions 3 and 5 refer to the labeled undirected graph below. There are eight nodes, each representing a city in the northeast United States. The edge from x to y, if it exists, is labeled with the driving distance from x to y as given by Google Maps. If there is no edge from x to y, we assume that it is only possible to drive from x to y along edges of the graph, through intermediate cities as necessary. Since the edges are undirected, the distance from x to y always equals the distance from y to x.

```
Montpelier ----180---- Augusta
/ | \ / |
/ | \ / |
/ | 117 163 |
/ | \ / |
158 153 \ / 166
/ | Concord |
/ | / | |
/ | 97 68 |
/ | | \ /
Albany --101-- Amherst --95-- Boston
\ | / |
113 53 _102_/ 51
\ | / |
\-- Hartford --74-- Providence
```

**Question 1 (20):**A**full b-ary tree of depth d**is defined as follows. A tree of depth 0 has a single node which is its root. A tree of depth d + 1 is defined to be b separate trees of depth d, with a new node that is the root, and a new edge from the new root to the root of each of the b separate trees.- (a, 10)
Determine how many
**leaves**a full b-ary tree of depth d has, as a function of b and d. Prove your claim, for arbitrary positive b, by ordinary induction on all naturals d. - (b, 10)
Prove that if b > 1, any full b-ary tree of depth d has exactly
(b
^{d+1}- 1)/(b - 1)**total nodes**. Again let b be an arbitrary positive integer with b > 1 and use ordinary induction on all naturals d.

- (a, 10)
Determine how many
**Question 2 (15):**My dog Duncan gets four servings of food a day. His food comes in cases of twelve cans, and each can has exactly five servings. (My other dog Cardie eats different food.)On Day 0, a Thursday, we opened a new case of food for his first meal.

- (a, 5) Find a positive natural k so that for every natural n, Day kn is a Thursday and we open a new case of food with his first meal on that day. (There are infinitely many values of k with this property, and any one of them will get full credit.)
- (b, 10) Prove your assertion in part (a) by ordinary induction on all naturals n, using the value of k you proposed there.

**Question 3 (25):**Above is a labeled undirected graph, where the eight nodes represent cities and the edges represent driving distance between certain pairs of cities.- (a, 5) For any two cities x and y, define d(x, y) to be
the
**minimum number of edges**for any path in the graph from x to y. Using a breadth-first search, find the value of d(x, Providence) for each of the eight cities x in the graph. - (b, 10) Trace a uniform-cost search with start node Amherst and goal node Providence.
- (c, 10) Trace an A
^{*}search with start node Amherst and goal node Providence, where the heuristic h(x) for any city x is given by h(x) = 50d(x, Providence). (Here d is the function defined in part (a) of this problem.)

- (a, 5) For any two cities x and y, define d(x, y) to be
the
**Question 4 (20+10):**Here is a rather silly two-player game. We have a single pile of n stones, where n is a positive integer. On any player's move, she may divide the pile into p equal subpiles, where p is any**prime number**, and then remove all but one pile. (So, for example, if n = 24, the player to move could make two piles and leave 12 stones, or make three piles and leave 8 stones. Don't forget that 1 is not a prime number.)The two players alternate moves until there is only one stone left, whereupon the player who cannot move loses the game. White moves first. So if n = 1, White cannot move and Black wins. If n = 2, White can make two piles of one stone each and remove one of them, leaving Black with one stone, so that Black than cannot move and White wins.

- (a, 5) Determine the winner, assuming optimal play by each player, for each initial value of n from n = 3 through n = 9.
- (b, 15) Prove, by strong induction on all positive
numbers n, that Black has a winning strategy in this game
when we start with n
^{2}stones. - (c, 10XC) Describe a boolean method that takes a
positive integer n and returns true if and only if White
wins the game starting with n stones, again assuming optimal
play by both players. You may use real Java, the book's
pseudo-Java, or other pseudocode as long as your algorithm
is clear.
For full credit, argue convincingly that your algorithm gives the correct answer for all n. (This might or might not involve an induction proof.)

**Question 5 (20):**The following are ten true/false questions, with no explanation needed or wanted, no partial credit for wrong answers, and no penalty for guessing. Each one counts two points.Parts (a)-(e) of this problem deal with a DFS of the labeled undirected graph above,

**using a closed list**, with Amherst as the start node and no goal node. In this DFS, when two cities enter the open list at the same time, the one that comes off first is the one that is**earlier in alphabetical order**. Thus the edge labels have no effect on the DFS' behavior.Parts (f)-(j) of this problem do not refer to the given graph.

- (a) The DFS tree from this search consists of a single path from the root to a single leaf.
- (b) The edge from Albany to Montpelier becomes a tree edge.
- (c) There is no articulation point in the original undirected graph.
- (d) Of the five edges with Boston as an endpoint, exactly two become tree edges.
- (e) Boston comes off of the open list before Hartford does.
- (f) Without a closed list or marking of nodes, a DFS of any finite directed graph is not guaranteed to find all the nodes reachable from the start.
- (g) Without a closed list or marking of nodes, a BFS of any finite directed graph is not guaranteed to find all the nodes reachable from the start.
- (h) If a directed graph with more than one node is strongly connected, each node must have at least one edge going into it and at least one edge going out of it.
- (i) Any undirected graph with no cycles is a tree.
- (j) Let Σ be a finite alphabet and let P(w) be a
predicate with one free variable whose type is "string in
Σ
^{*}". If I prove P(λ) and I prove ∀w:∀a: P(w) → P(wa), where the type of a is "letter in Σ", then I may conclude ∀w:P(w).

Last modified 12 April 2015