0% found this document useful (0 votes)
13 views6 pages

ps6 Sol

The document contains solutions to Problem Set 6 for a Mathematics for Computer Science course, addressing various mathematical concepts including equivalence relations, properties of functions, partial orders, and network design. Each problem is broken down with proofs or explanations demonstrating whether certain relations or functions meet specific criteria. The final problem discusses the design and characteristics of a Reasoner-net, comparing it to butterfly and Benes networks.

Uploaded by

sonleuid1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

ps6 Sol

The document contains solutions to Problem Set 6 for a Mathematics for Computer Science course, addressing various mathematical concepts including equivalence relations, properties of functions, partial orders, and network design. Each problem is broken down with proofs or explanations demonstrating whether certain relations or functions meet specific criteria. The final problem discusses the design and characteristics of a Reasoner-net, comparing it to butterfly and Benes networks.

Uploaded by

sonleuid1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

6.042/18.

062J Mathematics for Computer Science October 13, 2010


Tom Leighton and Marten van Dijk

Problem Set 6 Solutions

Due: Monday, October 19

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.

(a) [5 pts] Rn := {(x, y) ∈ Z × Z s.t. x ≡ y (mod n)}

Solution. It is an equivalence relation. To prove this, we will show that Rn is symmetric,


transitive, and reflexive.

ˆ Reflexive: x ≡ x (mod n). This is because x = x + 0 · n.


ˆ Symmetric: We want to show that Rn (x, y) ⇒ Rn (y, x). If Rn (x, y), then there is
some c ∈ Z such that x = y + c · n. But then, subtracting c · n from both sides, we
have that y = x + (−c) · n, so y ≡ x (mod n). So Rn (y, x), and the symmetric property
holds.
ˆ Transitivity. Suppose Rn (x, y) and Rn (y, z). From the first statement, we know that
there is some c ∈ Z such that x = y + c · n. From the second, we know that there
is some d ∈ Z such that y = z + d · n. Substituting in this value of y, we see that
x = (z + d · n) + c · n = z + (d + c) · n. The sum c + d is an integer, so Rn (x, z) holds.

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. 

(c) [5 pts] R := {(x, y) ∈ Z × Z s.t. gcd(x, y) = 1}

Solution. This is not an equivalence relation, because transitivity is broken. Consider


the case when x = 3, y = 7, and z = 15. Then, gcd(x, y) = 1 and gcd(y, z) = 1, but
gcd(x, z) = 3 6= 1. 
2 Problem Set 6

(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:

injective surjective bijective

Determine the properties of the functions below, and briefly explain your reasoning.

(a) [5 pts] The function f : R → R defined by f (x) = x sin(x).


Solution. This function is surjective, because for every y ∈ R there is a x ∈ R such that
x sin(x) = y. You can see that, because the function is continuous and for every positive
N there is an x such that f (x) > N and an x0 such that f (x0 ) < −N . The function is not
injective, because there are values of y which equal f (x1 ) = f (x2 ) for some different values
of x1 , x2 . For example, f (0) = f (π). Consequently, the function is not bijective either. 

(b) [5 pts] The function f : R → R defined by f (x) = 99x99 .


Solution. This function is surjective, because for every y ∈ R there is a x ∈ R such that
99x99 = y. You can see that, for the same reasons as the function in part a. The function
is also injective, because for every values of y ∈ R, there is exactly one x ∈ R such that
y = f (x). This holds, since the function is strictly increasing. Consequently, the function
is also bijective. 

(c) [5 pts] The function f : R → R defined by tan−1 (x).


Solution. This function is not surjective, because for all x ∈ R, − π2 ≤ tan−1 (x) ≤ π2 .
Consequently, there are some numbers y ∈ R, for example y = 3, such that no x ∈ R for
which y = tan−1 (x) exists. The function is also injective, because for every values of y ∈ R,
there is exactly one x ∈ R such that y = f (x). This holds, since the function is strictly
increasing. Finally, the funcion is not bijective, because it is not surjective. 
Problem Set 6 3

(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).

(a) [7 pts] Label the given sequence of (n − 1)(m − 1) + 1 integers a1 , a2 , . . . , a(n−1)(m−1)+1 .


Show the following relation  on {1, 2, 3, . . . , (n − 1)(m − 1) + 1} is a poset: i  j if and
only if i ≤ j and ai ≤ aj (as integers).

Solution. We show reflexivity, anti-symmetry, and transitivity. Clearly i  i since i ≤ i


and ai ≤ ai , so  is reflexive. Next, suppose i  j and j  i. Then i ≤ j ≤ i, so i = j, and
 is anti-symmetric. Finally, suppose i  j and j  k. Then i ≤ j and j ≤ k, so i ≤ k.
Moreover, ai ≤ aj and aj ≤ ak , so ai ≤ ak . Thus,  is transitive. 

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.

Solution. Consider the  relation on {1, 2, . . . , (n − 1)(m − 1) + 1} defined above. The


length of the longest non-decreasing subsequence of the given integers is just the length of
4 Problem Set 6

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.

diameter switch size(s) # switches congestion LMC CML

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. 

You might also like