Question text is in black, solutions are in blue.
Correction in orange added 1 April 2012.
Q1: 25 points Q2: 15 points Q3: 35+10 points Q4: 25 points Total: 100+10 points
Base Case: j = 0, f(0, 0) is defined to be 20 = 1, and this
equals 20+1 - 1 = 1.
Inductive Case: Assume that f(0, j) = 2j+1 - 1.
Then f(0, j+1) is defined to be f(0, j) + 2j+1, which
by the IH is equal to 2j+1 - 1 + 2j+1 =
2j+2 - 1 which is 2(j+1)+1 - 1 as required.
Let i be arbitrary and use induction on all j with j ≥ i.
Base Case: i = j, f(i, i) is defined to be 2i, and
this is equal to 2j+1 - 2i.
Inductive Case: Assume that f(i, j) = 2j+1 -
2i. Then f(i, j+1) is defined to be f(i, j) +
2j+1 which by the IH is 2j+1 - 2i
+ 2j+1 = 2j+2 - 2i. This is
2(j+1)+1 - 2i as required.
Question 2 deals with the inductive definition of addition of natural numbers, and with an inductively defined predicate LE(x, y) that takes two natural numbers as arguments.
Recall that x + 0 is defined to be x, and that x + succ(y) is defined to be succ(x + y), where "succ" is the successor function on naturals.
We define LE(x, y) by three rules. LE(0, y) is defined to be true for any y. LE(succ(x), 0) is defined to be false for any x. Finally, LE(succ(x), succ(y)) is defined to be equal to LE(x, y) for any naturals x and y.
Let x and y be arbitrary, and use ordinary induction on z.
Base Case: z = 0, we must prove LE(x, y) → LE(x + 0, y +
0), which is true because x + 0 = x and y + 0 = y.
Inductive Case: Assume that LE(x, y) implies LE(x + z, y + z).
We want to prove that LE(x, y) implies LE(x + succ(z), y +
succ(z)). Assume that LE(x, y) is true. Then the IH implies that
LE(x + z, y + z) is true. By the definition of addition, LE(x +
succ(z), y + succ(z)) equals LE(succ(x + z), succ(y + z)), which by
the definition of LE is equal to LE(x + z, y + z), which is true.
Question 3 deals with a particular directed graph with nine vertices s, a1, a2, a3, a4, b1, b2, b3, and b4. There are arcs from s to a1 and b1. For i = 1, 2, or 3, the nodes ai and bi each have arcs to nodes ai+1 and bi+1. Those are the only arcs -- there are 14 in all. We will consider depth-first and breadth-first searches of this directed graph starting at s, both with and without a closed list. (With a closed list, we can recognize visited nodes, including nodes on the stack or in the queue -- without one we cannot.) When we use DFS, the children ai and bi of a node are placed on the stack with bi placed first, so that ai is taken off the stack first. When we use BFS, ai is placed on the queue first, so that it comes off first.
Of course the closed list searches will terminate because there are
only finitely many nodes and arcs in the graph, and those
searches will only process each of these once.
With an open list, we are only guaranteed termination because
this particular directed graph has no cycles. A node is placed
on the open list once for each path from the start node to it,
and in this directed graph all paths are of length at most four
and every node has at most two neighbors, so there are finitely
many paths.
The tree has root s, with children a1 and b1. Node a1 has children a2 and b2 in the tree, a2 has children a3 and b3, a3 has children a4 and b4, and the other four nodes are leaves of the tree. The two arcs each out of b1, b2, and b3 are the non-tree edges.
The BFS tree is actually identical to the DFS tree, although the nodes are visited in a different order.
The node a4, for example, is the fifth node explored by the DFS, after s, a1, a2, and a3. But it is the seventh node explored by the BFS, followed only by b4.
The node b1 is the third node explored by the BFS, after only s and a1. But it is the last node explored by the DFS, as all the descendents of a1 are explored before b1 is considered.
There are eight visits to each of a4 and b4, or sixteen total. There is one visit of a node for each path from s to the node. There is one path to each node on level 1, two paths to each on level 2, four to each node on level 3, and finally eight to each on level 4.
The answer again is eight visits to each node, sixteen in all. When s is explored, a1 and b1 are put on the queue one time each. These two nodes each put their two children on the queue, so after they are explored there are four nodes on the queue. Similarly there are eight nodes (four copies each of a3 and b3) on the queue after the second level has been explored, and sixteen after the third level has been explored. These nodes each represent one visit to a childless node.
Question 4 deals with a two-player game called Stones. In Stones, there is a single pile with some natural number of stones in it. On her turn, a player must remove either one or two stones from the pile. The first player who cannot move loses. (That is, the player who takes the last stone wins.) The game is somewhat similar to another game called Nim that you may have seen, but Stones is easier to analyze.
If the first player takes one, take two. If she takes two, take one. Either way you (the second player) get the last stone.
Take one stone. The second player is now in the position of the first player in part (a), and will lose if you (the first player) follow the strategy given their for the second player.
Base case: k = 0, by definition of the game the first player loses
because she cannot take any stones.
Inductive case: Assume that the second player has a winning
strategy for the game with 3k stones. In the game with 3(k+1)
stones, the second player should take two on her first move if
the first player takes one, and should take one if the first
player takes two. She (the second player) is now the second
player in a game with 3k stones, and by the IH she has a winning
strategy for the remainder of the game.
Many students gave a correct strategy (always move to make
the remaining number of stones divisible by 3) but did not
express it as an induction. Others said to play the 3k game
first, then the 3 game (or vice versa), but did not explain how
the 3k+3 game could be decomposed into these two smaller games.
If the original number of stones is not divible by 3, it must be either 3k+1 or 3k+2 for some natural number k. On her first move, the first player should take one stone in the first case and two stones in the second case, so that she becomes the second player in a game with 3k stones. By part (c), she has a winning strategy for this remaining game.
Last modified 1 April 2012