ps6 Sol
ps6 Sol
Problem 1. [20 points] [15] For each of the following, either prove that it is an equivalence
relation and state its equivalence classes, or give an example of why it is not an equivalence
relation.
The equivalence classes are then the sets of numbers congruent to the numbers {0, 1, . . . , n−
1} modulo n.
(b) [5 pts] R := {(x, y) ∈ P × P s.t. x is taller than y} where P is the set of all people in
the world today.
Solution. This is not an equivalence relation, because the concept of symmetry is broken.
If y is taller than x, then x is not taller than y.
(d) [5 pts] RG := the set of (x, y) ∈ V × V such that V is the set of vertices of a graph G,
and there is a path x, v1 , . . . , vk , y from x to y along the edges of G.
Solution. This is an equivalence relation. We will show this by proving that it obeys
reflexivity, symmetry, and transitivity.
Reflexivity: Any vertex is connected to itself.
Symmetry: If RG (x, y), then there is a path x, v1 , . . . , vk , y from x to y. The reverse
of this path is y, vk , . . . , v1 , x, and is a path from y to x. So RG (y, x).
Transitivity: Suppose RG (x, y) and RG (y, z). Then, there is a path from x to y:
x, v1 , . . . , vk , y. Furthermore, there is a path from y to z: y, w1 , . . . , wl , z. But then,
the concatenation of those two is a path x, v1 , . . . , vk , y, w1 , . . . , wl , z from x to z. So
RG (x, z).
Thus we have shown that RG is an equivalence relation on a graph G, and the equivalence
classes are the connected components of G.
Problem 2. [20 points] Every function has some subset of these properties:
Determine the properties of the functions below, and briefly explain your reasoning.
(d) [5 pts] The function f : N → N defined by f (x) = the number of numbers that divide x.
For example, f (6) = 4 because 1, 2, 3, 6 all divide 6. Note: We define here the set N to be
the set of all positive integers (1, 2, . . .).
Solution. We claim that f is surjective but not injective. To see that it is not injective,
note that f (6) = 4 = f (10).
However, we must now show that it is surjective. Given number n, we know from the
fundamental theorem of arithmetic that it has a unique prime factorization pk11 pk22 . . . pkmm .
Note that the numbers that divide n are simply numbers of the form pr11 pr22 . . . prmm , where
ri ≤ ki for all indices i. Because the pi in this product are unique primes, every combination
of choices of exponents {ri } will
Q yield a different number that divides n. So the total number
of numbers that divides n is m i=1 ki . One easy way to see that f (n) is surjective, then, is
to consider n = 2 . Then, for any integer k, f (2k−1 ) = k. So f is surjective on the positive
k
integers.
Problem 3. [20 points] In this problem we study partial orders (posets). Recall that a
partial order on a set X is reflexive (x x), anti-symmetric (x y ∧ y x → x = y),
and transitive (x y ∧ y z → x z). Note that it may be the case that neither x y
nor y x. A chain is a list of distinct elements x1 , . . . , xi in X for which x1 x2 · · · xi .
An antichain is a subset S of X such that for all distinct x, y ∈ S, neither x y nor y x.
The aim of this problem is to show that any sequence of (n − 1)(m − 1) + 1 integers either
contains a non-decreasing subsequence of length n or a decreasing subsequence of length m.
Note that the given sequence may be out of order, so, for instance, it may have the form
1, 5, 3, 2, 4 if n = m = 3. In this case the longest non-decreasing and longest decreasing
subsequences have length 3 (for instance, consider 1, 2, 4 and 5, 3, 2).
For the next part, we will need to use Dilworth’s theorem, as covered in lecture. Recall that
Dilworth’s theorem states that if (X, ) is any poset whose longest chain has length n, then
X can be partitioned into n disjoint antichains.
(b) [7 pts] Show that in any sequence of (n − 1)(m − 1) + 1 integers, either there is a
non-decreasing subsequence of length n or a decreasing subsequence of length m.
the longest chain in this poset. If the longest chain has length at least n, we are done, so
suppose the length of the longest chain is at most c ≤ n − 1.
Then, by the first part we know that {1, 2, . . . , (n − 1)(m − 1) + 1} can be decomposed
into c disjoint antichains. Consider the indices i1 ≤ i2 ≤ · · · ≤ is in any antichain A. Then
it must be the case that ai1 > ai2 > · · · > ais , as otherwise we would have aij ≤ aij0 for
some j < j 0 , and thus j j 0 , and A could not be an antichain. It follows that there is a
decreasing subsequence of length at least |A|.
Since it is possible to partition {1, 2, . . . , (n−1)(m−1)+1} into c ≤ n−1 disjoint antichains,
one such antichain must have size at least
(n − 1)(m − 1) + 1 (n − 1)(m − 1) + 1 1
≥ ≥m−1+ ≥ m,
c n−1 n−1
which completes the proof.
(c) [6 pts] Construct a sequence of (n − 1)(m − 1) integers, for arbitrary n and m, that
has no non-decreasing subsequence of length n and no decreasing subsequence of length m.
Thus in general, the result you obtained in the previous part is best-possible.
Solution. Consider the set of integers {1, 2, . . . , (n − 1)(m − 1)}. For each 1 ≤ i ≤ n − 1,
define the decreasing subsequence of length m − 1:
Bi = i(m − 1), . . . , (i − 1)(m − 1) + 1.
Then the Bi partition {1, 2, . . . , (n − 1)(m − 1)}. Consider the sequence
S = B1 ◦ B2 ◦ · · · ◦ Bn−1 .
Any non-decreasing subsequence of S can contain at most one integer from any single Bi ,
since the Bi are decreasing subsequences. Thus, the length of the longest non-decreasing
subsequence is at most n − 1.
Any decreasing subsequence must be entirely contained in a single Bi , since for j > i, any
integer in Bj is larger than any integer in Bi . Thus, the length of the longest decreasing
subsequence is at most m − 1.
Problem 4. [20 points] Louis Reasoner figures that, wonderful as the Benes̆ network may
be, the butterfly network has a few advantages, namely: fewer switches, smaller diameter,
and an easy way to route packets through it. So Louis designs an N -input/output network
he modestly calls a Reasoner-net with the aim of combining the best features of both the
butterfly and Benes̆ nets:
The ith input switch in a Reasoner-net connects to two switches, ai and bi , and
likewise, the jth output switch has two switches, yj and zj , connected to it. Then
the Reasoner-net has an N -input Benes̆ network connected using the ai switches
as input switches and the yj switches as its output switches. The Reasoner-net
also has an N -input butterfly net connected using the bi switches as inputs and¡
the zj switches as outputs.
Problem Set 6 5
In the Reasoner-net the minimum latency routing does not have minimum congestion. The
latency for min-congestion (LMC) of a net is the best bound on latency achievable using
routings that minimize congestion. Likewise, the congestion for min-latency (CML) is the
best bound on congestion achievable using routings that minimize latency.
Fill in the following chart for the Reasoner-net and briefly explain your answers.
Solution.
diameter switch size(s) # switches congestion LMC CML
√
log N + 4 2×2 3N (log N + 1) 1 2 log N + 3 N
The diameter of a Reasoner-net is the smaller diameter of the two components plus 2 (to
connect to switch to input/output). The diameter of the butterfly component is log N + 2,
while the diameter of the Benes̆ component is 2 log N +1, so overall diameter is 2 + diameter
of butterfly = log N + 4.
The number of switches is the number of input and output switches in the Reasoner-net,
4N , plus the number of switches in its butterfly component, N (log N + 1), and its Benes̆
component, 2N log N .
The congestion is the congestion of the better of the two component nets, which is the
congestion of the Benes̆ component.
The LMC for the butterfly net equals its diameter, and likewise for the LMC of the Benes̆
net. So the LMC of the Reasoner-net is 2 plus the LMC of the routing through the
component with minimum congestion, namely, 2 plus the diameter of the Benes̆ net.
The CML equals the congestion of the routing through the component with minimum
latency, namely, the congestion of the butterfly net.
Problem 5. [20 points] Let Bn denote the butterfly network with N = 2n inputs and √N
outputs, as defined in Notes 6.3.8. We will show that the congestion of Bn is exactly N
when n is even.
Hints:
For the butterfly network, there is a unique path from each input to each output, so
the congestion is the maximum number of messages passing through a vertex for any
matching of inputs to outputs.
If v is a vertex at level i of the butterfly network, there is a path from exactly 2i input
vertices to v and a path from v to exactly 2n−i output vertices.
At which level of the butterfly network must the congestion be worst? What is the
congestion at the node whose binary representation is all 0s at that level of the network?
6 Problem Set 6
√
(a) [10 pts] Show that the congestion of Bn is at most N when n is even.
√
Solution. First we will show that the congestion is at most N .
Let v be an arbitrary vertex at some level i. Let Sv be the set of inputs that can reach
vertex v. Let Tv be the set of outputs that are reachable from vertex v.
By the hint, we have |Sv | = 2i and |Tv | = 2n−i . The number of inputs in Sv that are
matched with outputs in Tv is at most min {2i , 2n−i }. To obtain an upper-bound on the
congestion of the network, we need to find the maximum value of min {2i , 2n−i }, where the
maximum is taken over all i. The maximum value is achieved when 2i and 2n−i are as
equal as possible. Since n is even, these two quantities are equal when i = n/2, hence the
maximum congestion is √
2n/2 = N 1/2 = N .
√
(b) [10 pts] Show that the congestion √ achieves N somewhere in the network and conclude
that the congestion of Bn is exactly N when n is even.
√
Solution. We concluded that the congestion of N can be achieved only at a node at
level n2 . Consider the node at that level whose binary representation is all 0s. Any packet
from the input in the form z 0| . .{z
. 000} with destination 000
| {z. . . 0} z 0 , where z and z 0 are any
n/2 bits n/2 bits
n
-bitnumbers, must pass through this node. In the worse case, all packets from input in
2 √
the form z 0| . .{z . . . 0} z 0 . But there are 2n/2 = N
. 000} will have destination in the form |000{z
n/2 bits n/2 bits
√
of such possible packets, giving
√ the node load N . Therefore, we can conclude that the
congestion of Bn is exactly N when n is even.