Midterm 2 solutions

CSC 10400: Discrete Mathematical Structures (Spring 2015)
Midterm 2
Name: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Problem
1
2
3
4
5
6
7
8
9
10
11
Total
Score
There are 11 questions in exam. Each of them is worth 10 points. You can
choose 10 of them. If you answer all 11 questions, the extra one will be considered
as a bonus question.
Good Luck!
1
1. For any m, n ∈ N, the Ackermann’s function A(m, n) is defined recursively as follows.


if m = 0, n ≥ 0
 n+1
A(m, n) =
A(m − 1, 1)
if m > 0, n = 0

 A(m − 1, A(m, n − 1)) if m > 0, n > 0
Use mathematical induction, prove that
(a) A(1, n) = n + 2 for every n ∈ N.
Answer:
Proof. When n = 0, A(1, n) = A(1, 0) = A(0, 1) = 1 + 1 = 2. n + 2 = 2. Thus,
A(1, n) = n + 2 holds for n = 0.
Suppose A(1, n) = n + 2 holds for n = k for some k ∈ N. When n = k + 1, we have
A(1, k + 1) = A(0, A(1, k))
= A(0, k + 2)
= (k + 2) + 1
= (k + 1) + 2
Therefore, by mathematical induction, A(1, n) = n + 2 holds for every n ∈ N.
(b) A(2, n) = 2n + 3 for every n ∈ N.
Answer:
Proof. When n = 0, A(2, 0) = A(1, 1) = 1+2 = 3. 2n+3 = 3. Thus, A(2, n) = 2n+3
holds for n = 0.
Suppose A(2, n) = 2n + 3 holds for n = k for some k ∈ N. When n = k + 1, we have
A(2, k + 1) = A(1, A(2, k))
= A(1, 2k + 3)
= 2k + 3 + 2
= 2(k + 1) + 3
Therefore, by mathematical induction, A(2, n) = 2n + 3 holds for every n ∈ N.
2
2. (a) Use Euclidean algorithm, compute gcd(55, 89). Please write down each step in the
computation.
Answer:
89 = 1 × 55 + 34
55 = 1 × 34 + 21
34 = 1 × 21 + 13
21 = 1 × 13 + 8
13 = 1 × 8 + 5
8=1×5+3
5=1×3+2
3=1×2+1
2=2×1
Thus, gcd(55, 89) = 1.
(b) Compute lcm(55, 89).
Answer:
lcm(55, 89) =
55×89
gcd(55,89)
=
55×89
1
= 55 × 89 = 4895.
3
3. Let A = {x, y, z} and B = {1, 2, 3, 4, 5, 6}. Determine each of the following.
(a) |A × B|.
Answer:
|A × B| = |A| × |B| = 3 × 6 = 18.
(b) The number of relations from A to B.
Answer:
A relation from A to B is a subset of A×B. Since |A×B| = 18, there are 218 = 262144
relations from A to B.
(c) The number of functions from A to B.
Answer:
We need to select 3 elements from B as images of elements in A with repetition. For
each selection, we have 6 choices. Therefore, there are 63 = 216 functions from A to
B.
(d) The number of injective functions from A to B.
Answer:
We need to select 3 elements from B as images of elements in A without repetition.
6!
720
Therefore, there are P (6, 3) = (6−3)!
= 6!
3! = 6 = 120 injective functions from A to
B.
(e) The number of surjective functions from A to B.
Answer:
Since |A| < |B|, there is no surjective functions from A to B.
4. Let A = {1, 2, 3, 4, . . . , 18}. Let S be an arbitrary subset of A with |S| = 7. Prove that
there exists two nonempty subsets of S so that the sum of elements in the two subsets
are equal.
Answer:
Proof. Because |S| = 7, there are 27 − 1 = 127 nonempty subsets of S.
Let T ⊆ S. |T | ≤ |S| = 7. Because every element in T is between 1 and 18, the sum of
element in T is at least 1 and at most 7 × 18 = 126.
Therefore, we have 127 nonempty subsets of S, and there are 126 different results for
the sum of elements in these subsets. By the pigeonhole principle, there exists d 127
126 e = 2
subsets of S so that the sum of elements in the two subsets are equal.
4
5. Professor Powell has 10 C++ books with different titles. He want to give these books to
three students: Tom, Jerry and Mary.
(a) How many ways can Professor Powell give 10 books to 3 students so that every
student has at least one book (You are not required to calculate the exact number,
but are required to write down the formula)?
Answer:
Let A be the set of 10 C++ books with different titles, and let B be the set of 3
students.
We define a function f : A → B defined by f = {(x, y)|x ∈ A, y ∈ B, y was given the book x}.
Because every student has at least one book, the function is surjective. Therefore, the
number of ways that the professor gives books to students is the number of surjective
functions from A to B. Therefore, the answer is 3!S(10, 3) = 55980.
(b) How many ways can Professor Powell give 10 books to 3 students so that every
student has at least one book and Tom gets “C++ Pimer”, one of the 10 books (You
are not required to calculate the exact number, but are required to write down the
formula)?
Answer:
Let the professor give “C++ Primer” to Tom first. Then, the professor have to give
the other 9 books to these 3 students. There are two cases:
• Case 1: Tom was given only one book
Professor Powell gives the other 9 books to Jerry and Mary so that both of them
are given at least one book.
• Case 2: Tom was given more than one book
Professor Powell gives the other 9 books to Tom, Jerry and Mary, so that every
student is given at least one book.
Both cases asks the number of surjective functions. In Case 1, there are 2!S(9, 2)
ways; in Case 2, there are 3!S(9, 3) ways. Therefore, by rule of sum, there are
2!S(9, 2) + 3!S(9, 3) = 18660 ways.
5
6. Let A = {0, 1, 2, 3, 4, 5}. Define a relation R on A as: R = {(x, y)|x, y ∈ A, (x + y) ≡
0 mod 3}.
(a) Write down the zero-one matrix corresponding to the relation R.
Answer:
First, we determine the relation R as
R = {(0, 0), (0, 3), (1, 2), (1, 5), (2, 1), (2, 4), (3, 0), (3, 3), (4, 2), (4, 5), (5, 1), (5, 4)}
The corresponding zero-one matrix is:









1
0
0
1
0
0
0
0
1
0
0
1
0
1
0
0
1
0
1
0
0
1
0
0
0
0
1
0
0
1
0
1
0
0
1
0









(b) Draw the directed graph corresponding to the relation R.
Answer:
The corresponding directed graph is drawn as follows.
6
7. For each of the following relation R, determine whether the relation is reflexive, symmetric, antisymmetric, transitive, a partial order, or an equivalence relation.
(a) R = {(x, y)|x, y ∈ Z, x + y − xy is even}.
Answer:
• R is not reflexive
When 1 + 1 − 1 × 1 = 1 is not even, i.e., (1, 1) ∈
/ R.
• R is symmetric.
If (x, y) ∈ R, x + y − xy = y + x − yx is even, i.e., (y, x) ∈ R.
• R is not antisymmetric.
Consider x = 2 and y = 4, 2+4−2×4 is even, so (2, 4) ∈ R. Similary, (4, 2) ∈ R.
However, 2 6= 4.
• R is transitive.
Suppose (x, y) ∈ R. If y is odd, since x + y − xy is even, x − xy = x(1 − y) is
odd. However, because 1 − y is even, x(1 − y) is even, a contradiction. Thus y
is even. When y is even, by x + y − xy is even, we can conclude that x is also
even. Thus, if (x, y) ∈ R, both x and y are even.
Therefore, if (x, y) ∈ R and (y, z) ∈ R, we can conclude that x, y and z are all
even, implying x + z − xz is even, i.e., (x, z) ∈ R.
• R is not a partial order.
R is not reflexive.
• R is not an equivalence relation.
R is not reflexive.
(b) R = {(x, y)|x, y ∈ Z, x ≡ y mod 4}.
Answer:
• R is reflextive.
x ≡ x mod 4 for any x ∈ Z.
• R is symmetric.
If (x, y) ∈ R, we have x ≡ y mod 4. It implies that y ≡ x mod 4, i.e., (y, x) ∈ R.
• R is not antisymmetric.
(0, 4) ∈ R and (4, 0) ∈ R, but 0 6= 4.
• R is transitive.
If (x, y) ∈ R, x ≡ y mod 4, i.e., x = y + 4k for some k ∈ Z. Similarly, if
(y, z) ∈ R, y = z + 4m for some z ∈ Z. Thus, x = z + 4(k + m) where k + m ∈ Z,
implying x ≡ z mod 4, i.e., (x, z) ∈ R.
• R is not a partial order.
R is not antisymmetric.
• R is an equivalence relation.
R is reflexive, symmetric and transitive.
7
8. Let S = R∗ × R, and define a binary operation ⊕ on S as (a, b) ⊕ (c, d) = (ac, bc + d).
Prove that the algebraic structure (S, ⊕) is a group.
Answer:
Proof. We prove it by verify the conditions in the definition.
• ⊕ is closed on S.
For any a, c ∈ R∗ and b, d ∈ R, (a, b) ⊕ (c, d) = (ac, bc + d). We have ac ∈ R∗ and
bc + d ∈ R, i.e., (ac, bc + d) ∈ R∗ × R = S. Thus, ⊕ is closed on S.
• ⊕ is associative.
For any a, b, c ∈ R∗ and x, y, z ∈ R, we have
(a, x) ⊕ ((b, y) ⊕ (c, z)) = (a, x) ⊕ (bc, yc + z)
= (abc, xbc + yc + z)
((a, x) ⊕ (b, y)) ⊕ (c, z) = (ab, xb + y) ⊕ (c, z)
= (abc, (xb + y)c + z)
= (abc, xbc + yc + z)
Therefore, ⊕ is associate on S.
• There exists an identity of ⊕.
Suppose (e1 , e2 ) ∈ S is the identity. For any (a, b) ∈ S, we must have (a, b) ⊕
(e1 , e2 ) = (a, b) ⇒ (ae1 , be1 + e2 ) = (a, b), implying e1 = 1 and e2 = 0.
We claim that (1, 0) ∈ S is the identity. For any (a, b) ∈ S, we have (a, b) ⊕ (1, 0) =
(a × 1, b × 1 + 0) = (a, b) and (1, 0) ⊕ (a, b) = (1 × a, 0 × a + b) = (a, b). Clearly,
(1, 0) is the identity.
• There exists an inverse for every element in S.
Let (a, b) ∈ S. Suppose (x, y) is the inverse of (a, b), we must have (a, b) ⊕ (x, y) =
(1, 0). Thus, we need (ax, bx + y) = (1, 0), implying x = a1 and y = −bx = −b
a .
∗
∗
Since a ∈ R and b ∈ R, we have x ∈ R and y ∈ R, i.e., (x, y) ∈ S.
Now, we claim that ( a1 , −b
a ) ∈ S is the inverse of (a, b) for any (a, b) ∈ S. We have
1 −b
1
1
1
−b
(a, b) ⊕ ( a , a ) = (a a , b a − ab ) = (1, 0) and ( a1 , −b
a ) ⊕ (1, 0) = ( a a, a a + b) = (1, 0).
Clearly, ( a1 , −b
a ) is the inverse of (a, b).
Therefore, by the definition, S is a group.
8
9. Let (G, ⊕) be a group with G = {0, 1, 2, 3, 4, 5} and x ⊕ y = (x + y) mod 6, shown in the
following table.
⊕
0
1
2
3
4
5
0
1
2
3
4
5
0
1
2
3
4
5
1
2
3
4
5
0
2
3
4
5
0
1
3
4
5
0
1
2
4
5
0
1
2
3
5
0
1
2
3
4
(a) Let H = {0, 2, 4}. Prove that (H, ⊕) is a subgroup of (G, ⊕).
Answer:
Proof. Because H is a finite subset of G, we only need to prove that ⊕ is closed on
H.
We extract the result of x ⊕ y for x, y ∈ H as follows.
⊕
0
2
4
0
2
4
0
2
4
2
4
0
4
0
2
Clearly, ⊕ is closed on H. Therefore, (h, ⊕) is a subgroup of (G, ⊕).
(b) Write down the left coset 1H and the right coset H3.
1H = {1, 3, 5} and H3 = {3, 5, 1}, shown in the following table.
⊕
0
2
4
1
1
3
5
9
⊕
3
0
2
4
3
5
1
10. Let the algebraic structure (S, ⊕, ⊗) is defined by: S = R+ , x ⊕ y = xy, and x ⊗ y =
xlog2 y .
(a) Prove that the (S, ⊕, ⊗) is a ring.
Answer:
Proof. First, ⊕ and ⊗ is closed on S. For any x, y ∈ R+ , xy ∈ R+ and xlog2 y ∈ R+ .
Then, we verify the six conditions in the definition of rings.
• ⊕ is commutative.
For any x, y ∈ R+ , xy = yx.
• ⊕ is associative.
For any x, y, z ∈ R+ , x(yz) = (xy)z.
• There exists an identity of ⊕ on S.
The additive identity is 1. For any x ∈ R+ , x ⊕ 1 = 1 ⊕ x = x.
• There exists an inverse of ⊕ for every element in S.
For any x ∈ R+ , x1 ∈ R+ is its additive inverse, because x⊕ x1 = x1 ⊕x = x x1 = 1.
• ⊗ is associative.
log z
For any x, y, z ∈ R+ , x ⊗ (y ⊗ z) = x ⊗ (y log2 z ) = xlog2 (y 2 ) = xlog2 z log2 y .
(x ⊗ y) ⊗ z = (xlog2 y ) ⊗ z = (xlog2 y )log2 z = xlog2 y log2 z . Thus, x ⊗ (y ⊗ z) =
(x ⊗ y) ⊗ z.
• Distributive laws on ⊗ over ⊕.
For any x, y, z ∈ R+ , we have x ⊗ (y ⊕ z) = x ⊗ (yz) = xlog2 (yz) = xlog2 y+log2 z =
xlog2 y xlog2 z = (x ⊗ y)(x ⊗ z) = (x ⊗ y) ⊕ (x ⊗ z) and (x ⊕ y) ⊗ z = (xy) ⊗ z =
(xy)log2 z = xlog2 z y log2 z = (x ⊗ z)(y ⊗ z) = (x ⊗ z) ⊕ (y ⊗ z).
Therefore, (S, ⊕, ⊗) is a ring.
(b) Prove that this ring is a field.
Answer:
Proof. First, we show that (S, ⊕, ⊗) is a commutative ring with unity.
• (S, ⊕, ⊗) is a commutative ring.
For any x, y ∈ R+ , Let k = x ⊗ y = xlog2 y . We have log2 k = log2 (xlog2 y ) =
log2 y log2 x = log2 x log2 y = log2 (y log2 x ) = log2 (y ⊗ x), implying that x ⊗ y =
k = y ⊗ x. Therefore, (S, ⊕, ⊗) is a commutative ring.
• (S, ⊕, ⊗) has a unity.
Suppose u is the unity. Let x ∈ R+ , we need x ⊗ u = x ⇒ xlog2 u = x ⇒
log2 u = 1 ⇒ u = 2. We claim that u = 2 is the unity, because for any x ∈ R+ ,
x ⊗ u = xlog2 2 = x1 = x, and u ⊗ x = x ⊗ u = x.
For each x ∈ R+ with x 6= z where z = 1 is the additive identity, we want find its
multiplicative inverse. Let y be the multiplicative inverse of x, we have x ⊗ y =
xlog2 y = u = 2 ⇒ log2 x log2 y = 1 ⇒ log2 y = log1 x ⇒ y = 21/ log2 x . Because
2
x ∈ R+ and x 6= 1, y = 21/ log2 x ∈ R+ . Therefore, every nonzero element in S has a
multiplicative inverse, i.e., (S, ⊕, ⊗) is a field.
10
11. Use mathematical induction, prove that
S(n) = 2! × 4! × 6! × . . . × (2n)! ≥ ((n + 1)!)n
Answer:
Proof. When n = 1, S(n) = 2! = 2. ((n + 1)!)n = (2!)1 = 2. Thus, S(n) ≥ ((n + 1)!)n
holds for n = 1.
Suppose S(n) ≥ ((n + 1)!)n holds for n = k. When n = k + 1, we have
S(k + 1) = S(k) × (2(k + 1))!
≥ ((k + 1)!)k (2k + 2)!
= ((k + 1)!)k (k + 2)! × (k + 3) × (k + 4) × . . . × (2k + 2)
= ((k + 1)!)k (k + 2)!
≥ ((k + 1)!)k (k + 2)!
k
Y
i=1
k
Y
(k + 2 + i)
(k + 2)
i=1
= ((k + 1)!)k (k + 2)!(k + 2)k
= ((k + 1)!(k + 2))k (k + 2)!
= ((k + 2)!)k (k + 2)!
= ((k + 2)!)k+1
Therefore, by mathematical induction, S(n) ≥ ((n + 1)!)n holds for every n ∈ Z+ .
11