
CS173: Discrete Mathematical Structures
Spring 2006
Homework #11
Due 04/23/05, 8a
Solutions, Grading Rubric
(43 Points)
1. (3 points each part for total of 12 points) In the Tower of Hanoi puzzle, suppose
our goal is to transfer all n disks from peg 1 to peg 3, but we cannot move a disk
directly between pegs 1 and 3. Each move of a disk must be a move involving
peg 2. As usual, we cannot place a disk on top of a smaller disk.
a. Find a recurrence relation for the number of moves required to solve the
puzzle for n disks with this added restriction.
b. Solve this recurrence relation to find a formula for the number of moves
required to solve the puzzle for n disks.
c. How many different arrangements are there of the n disks on three pegs so
that no disk is on top of a smaller disk?
d. Use your answers to parts b and c to argue that every allowable
arrangement of the n disks occurs in the solution of this variation of the
puzzle.
Solutions:
a. If we have one disk, then we move it to peg 2, then to peg 3. Thus a1=2.
Suppose the number of moves needed to move n disks from peg 1 to peg 3
is an. To move n+1 pegs, we have to move the n pegs from peg 1 to peg 3,
then move the largest disk to peg 2, then move n disks from peg 3 to peg
1, then move the largest disk to peg 3, and finally move the n disks to peg
3. Thus an= 3an-1+2.
b. (E-1)(E-3)=<0>. Thus the solution is: an=A+B3n. a1=2, a2=8 (you can get
this both from the recursive formula for an and by manually solving the
problem with two disks). We get A+3B=2; A+9B=8. Subtract equations to
get 6B=6. Thus B=1, A=-1, an=3n-1.
c. 3n.
d. During our solution no configuration can appear twice, since we have a
deterministic algorithm here. If we start with configuration X and after k
steps reach configuration X again, then we’ll return to the same
configuration at times k, 2k, 3k,… never solving the problem. Now, we
start with the initial configuration and have additional 3n-1 distinct
configurations until we solve the problem. Thus we see 3n-1+1
configurations during the solutions, which is all the possible
configurations.
2. (3 points each part for total of 15 points) Solve the following recurrences exactly: