Midterm Practice Problems: N N 1 N 2 N 3 N 4
Midterm Practice Problems: N N 1 N 2 N 3 N 4
Midterm Practice Problems: N N 1 N 2 N 3 N 4
1
if 0 n 3,
an =
an1 + an2 + an3 + an4 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).
In particular, since each of an4 , an3 , an2 and an1 is 1 (mod 3), their sum must be
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)
1 2 3 4 5 6 7 8 9
t
righ
ft
shi
1 2 3 4 5 6 7 8 9
rotate disc
shi
1 2 6 5 4 3 7 8 9
ft le
ft
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:
Initial State
2 1 3 4 5 6 7 8 9
Goal State
1 2 3 4 5 6 7 8 9
Conclusion: Since all reachable states have an odd number of inversions and the goal state
has an even number of inversions (specically 0), the goal state cannot be reached.
Problem 4. [10 points] Find the multiplicative inverse of 17 modulo 72 in the range
{0, 1, . . . , 71}.
Solution. Since 17 and 72 = 23 32 are relatively prime, an inverse exists and can be found
by either Eulers theorem or the Pulverizer.
Solution 1: Eulers Theorem
(72) = (23 32 )
= (23 ) (32 )
= (23 22 )(32 31 )
= 4 6 = 24
Therefore, 17(72)1 = 1723 is an inverse of 17. To nd the inverse in the range {0, 1, . . . , 71}
we take the remainder using the method of repeated squaring:
17 = 17
172 = 289
1
4
17 12 = 1
178 1
. . . etc.
(since 289 = 4 72 + 1)
y
17
4
rem xy = x q y
4 = 72 4 17
1 = 17 4 4
= 17 4 (72 4 17)
= 17 17 4 72
0
Problem 5. [15 points] Consider a graph representing the main campus buildings at MIT.
7
10
(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 5 continued...
Now suppose each building has separate mail collection and drop-o boxes and each collection
box has a single package destined for a unique drop-o box (i.e. a permutation). We can
model this as a permutation routing problem by treating the buildings as switches, attaching
an input and output terminal to each of the nine buildings, and treating the existing edges
as bidirectional as in the graph below:
(d) [4 pts] What is the max congestion of this graph? That is, in the worst case permutation,
how many packages would need to pass through a single building? Provide a brief argument
for your answer.
Solution. The maximum congestion is 9. Consider a permutation where all the packages
on the left side are destined for drop-os on the right side and vice versa with the building
10 package destined for building 10. In this case, all 9 packages must pass through building
10, giving a congestion of 9, which is the maximum for a graph with nine input-output
pairs.
2. symmetric
Solution. The beats relation is not symmetric by the denition of a tournament:
if x beats y then y does not beat x.
3. antisymmetric
Solution. The beats relation is antisymmetric since for any distinct players x and
y, if x beats y then y does not beat x.
4. reexive
Solution. The beats relation is not reexive 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, K4 , is not outerplanar but any proper
subgraph of K4 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
dierent 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
dier by at most 1.
n
i3
i=1
n
n
1
1
1
+
dx
3
3
i
x
1
i=1
1
n
= 1 x2
2
1
1 1
3
1
=1
1 = 2
2
2 n
2 2n
n
n
1
1
1
+
dx
3
3
3
i
n
x
1
i=1
1
1
n
= 3 x2
n
2
1
1
1 1
1
1
1
= 3
1
=
+
n
2 n3 2n2
2 n2
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.
(a)
6n2 + 7n 10
(b)
6n
6
n
(c)
n!
O, o
(nn )
(d)
1
j=1
(e)
ln(n3 )
= O, ,
n2
= O, , , (ln n)
= O, , (ln n)
MIT OpenCourseWare
http://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.