






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







6.042/18.062J Mathematics for Computer Science October 21, 2010
Tom Leighton, Marten van Dijk, and Brooke Cowan
Problem 1. [10 points] In problem set 1 you showed that the nand operator by itself can be
used to write equivalent expressions for all other Boolean logical operators. We call such an
operator universal. Another universal operator is nor, defined such that P norQ ⇔ ¬(P ∨Q).
Show how to express P ∧ Q in terms of: nor, P , Q, and grouping parentheses.
Solution. ( ¬P ) nor ( ¬Q) = (P nor P ) nor (Q nor Q). �
Problem 2. [15 points] We define the sequence of numbers
1 if 0 ≤ n ≤ 3, an = an− 1 + an− 2 + an− 3 + an− 4 if n ≥ 4.
Prove that an ≡ 1 (mod 3) for all n ≥ 0.
Solution. Proof by strong induction. Let P (n) be the predicate that an ≡ 1 (mod 3).
Base case: For 0 ≤ n ≤ 3, an = 1 and is therefore ≡ 1 (mod 3).
Inductive step: For n ≥ 4, assume P (k) for 0 ≤ k ≤ n in order to prove P (n + 1).
In particular, since each of an− 4 , an− 3 , an− 2 and an− 1 is ≡ 1 (mod 3), their sum must be
≡ 4 ≡ 1 (mod 3). Therefore, an ≡ 1 (mod 3) and P (n + 1) holds. �
Problem 3. [20 points] The Slipped Disc Puzzle� consists of a track holding 9 circular
tiles. In the middle is a disc that can slide left and right and rotate 180
◦ to change the
positions of exactly four tiles. As shown below, there are three ways to manipulate the
puzzle:
Shift Right: The center disc is moved one unit to the right (if there is space)
Rotate Disc: The four tiles in the center disc are reversed
Shift Left: The center disc is moved one unit to the left (if there is space)
shift right
rotate disc
shift left
1 2 3 4 5 6 7 8 9 1 2 6 5 4 3 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
Prove that if the puzzle starts in an initial state with all but tiles 1 and 2 in their natural
order, then it is impossible to reach a goal state where all the tiles are in their natural order.
The initial and goal states are shown below:
2 1 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
Write your proof on the next page...
Solution. Order the tiles from left to right in the puzzle. Define an inversion to be a pair
of tiles that is out of their natural order (e.g. 4 appearing to the left of 3).
Lemma. Starting from the initial state there is an odd number of inversions after any number
of transitions.
Proof. The proof is by induction. Let P (n) be the proposition that starting from the initial
state there is an odd number of inversions after n transitions.
Base case: After 0 transitions, there is one inversion, so P (0) holds.
Inductive step: Assume P (n) is true. Say we have a configuration that is reachable after
n + 1 transitions.
In this case, the left-to-right order of the discs does not change and thus the number
of inversions remains the same as in
Problem 4. [10 points] Find the multiplicative inverse of 17 modulo 72 in the range
{ 0 , 1 ,... , 71 }.
Solution. Since 17 and 72 = 2
3 3
2 are relatively prime, an inverse exists and can be found
by either Euler’s theorem or the Pulverizer.
Solution 1: Euler’s Theorem
φ(72) = φ(
3 3
2 · )
= φ(
3 ) φ(
2 ) (since 2
3 and 3
2 · are rel. prime)
3 − 2
2 )(
2 − 3
1 ) (since 2 and 3 are prime)
Therefore, 17
φ(72)− 1 = 17
23 is an inverse of 17. To find the inverse in the range { 0 , 1 ,... , 71 }
we take the remainder using the method of repeated squaring:
2 = 289
≡ 1 (since 289 = 4 · 72 + 1)
4 ≡ 1
2 = 1
8 ≡ 1
... etc.
Therefore the inverse of 17 in the range { 0 , 1 ,... , 71 } is given by,
23 = 17
16 17
4 17
2 17
1
Solution 2: The Pulverizer
x y rem xy = x − q ·y
Since 17
2 − 4 72 = 1, 17
2 · ≡ 1 (mod 72) and so 17 is self inverse. �
Problem 5. [15 points] Consider a graph representing the main campus buildings at MIT.
(a) [3 pts] Is this graph bipartite? Provide a brief argument for your answer.
Solution. No, there is an odd-length cycle �
(b) [4 pts] Does this graph have an Euler circuit? Provide a brief argument for your answer.
Solution. This graph does not have an Euler circuit because there are vertices with odd
degree �
Problem 6. [10 points]
A tournament graph G = (V, E) is a directed graph such that there is either an edge from u
to v or an edge from v to u for every distinct pair of nodes u and v. (The nodes represent
players and an edge u →v indicates that player u beats player v.)
Consider the “beats” relation implied by a tournament graph. Indicate whether or not each
of the following relational properties hold for all tournament graphs and briefly explain your
reasoning. You may assume that a player never plays herself.
Solution. The “beats” relation is not transitive because there could exist a cycle of
length 3 where x beats y, y beats z and z beats x. By the definition of a tournament,
x cannot then beat y in such a situation. �
Solution. The “beats” relation is not symmetric by the definition of a tournament:
if x beats y then y does not beat x. �
Solution. The “beats” relation is antisymmetric since for any distinct players x and
y, if x beats y then y does not beat x. �
Solution. The “beats” relation is not reflexive since a tournament graph has no
self-loops. �
Problem 7. [20 points] An outerplanar graph is an undirected graph for which the vertices
can be placed on a circle in such a way that no edges (drawn as straight lines) cross each
other. For example, the complete graph on 4 vertices, K 4 , is not outerplanar but any proper
subgraph of K 4 with strictly fewer edges is outerplanar. Some examples are provided below:
Prove that any outerplanar graph is 3-colorable. A fact you may use without proof is that
any outerplanar graph has a vertex of degree at most 2.
Solution. Proof. Proof by induction on the number of nodes n with the induction hypothesis
P (n) = ”every outerplanar graph with n vertices is 3-colorable.”
Base case: For n = 1 the single node graph with no edges is trivially outerplanar and
3-colorable.
Inductive step: Assume P (n) holds and let Gn+1 be an outerplanar graph with n+1 vertices.
There must exist a vertex v in Gn+1 with degree at most 2. Removing v and all its incident
edges leaves a subgraph Gn with n vertices.
Since Gn+1 could be drawn with its vertices on a circle and its edges drawn as straight lines
without intersections, any subgraph can also be drawn in such a way and so Gn is also an
outerplanar graph. P (n) implies Gn is 3-colorable. Therefore we can color all the vertices
in Gn+1 other than v using only 3 colors and since deg(v) ≤ 2 we may color it a color
different than the vertices adjacent to it using only 3 colors. Therefore, Gn+1 is 3-colorable
and P (n + 1) holds.
Problem 8. [10 points] Give upper and lower bounds for the following expression which
differ by at most 1.
n
i=
Solution. To find upper and lower bounds, we use the integral method:
i^3
n 1
i^3
3
dx
1 x
n
i=
1 = 1 − 2
n
x
− 2
1
1 1 3 1 = 1 − 2 n
2
2 n
2
n 1
i^3
n^3
1 x
3
dx
n
i=
n^3
n
x
− 2
1
n
3
2 n
2
n
3
2 n
2
Problem 9. [15 points] Circle every symbol on the left that could correctly appear in the
box to its right. For each of the six parts you may need to circle any number of symbols.
MIT OpenCourseWare http://ocw.mit.edu
6.042J / 18.062J Mathematics for Computer Science
Fall 2010
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.