Solutions to the Final Test

Solutions to the Final Test
I601 Logic and Discrete Mathematics
Version A
1. Prove that for n > 6, there are exactly 3 trees with n vertices and maximum
degree n − 3 , up to isomorphism.
Let v be the vertex which has n − 3 neighbours. v together with its neighbourhood N (v) =
{v1 , v2 , . . . , vn−3 } consists n − 2 vertices in total. Remaining two vertices, say r and s, have to
be connected to one vertex (say to v1 ) or two vertices (say, to v1 and v2 ). As it is a tree, there
cannot be any edge between vertices of N (v).
If r and s are connected to v1 , there are two cases: (i) both are directly connected to v1 (there
are edges v1 –s and (v1 –r), or they form a path (it is v1 –s–r). If s and r are connected to v1 and
v2 , then there is only one possibility: v1 –r and v2 –s.
As we have unlabelled trees here, then any reordering of vertices of N (v) or r and s leads to
the tree that is isomorphic to one of the trees above. So, we have here exactly three trees. The
following picture depicts them:
2.
Solve the following recurrence relation (do not forget verification of the result):

 a0 = 0
a1 = −1

an − 7an−1 + 12an−2 = 0
for n > 2 :
S o l u t i o n.
Step 1 The associated characteristic equation is x2 − 7x + 12 = 0 and its two roots are x1 = 3
and x2 = 4.
Step 2 We note that (i) the nonhomogeneous part is 0 and (ii) all characteristic roots are
distinct. Thus, the general solution to the given recurrence equation is
an = A3n + B4n .
Step 3 We use the initial conditions to solve the following equations for the unknown constants
A and B:
n=0:
0 =A+B
=⇒ A = 1, B = −1
n = 1 : −1 = 3A + 4B
Therefore, an = 3n − 4n .
Step 4 For verification find from the equation a2 = 7a1 − 12a0 = −7 and check the result
a0 = 30 − 40 = 1 − 1 = 0
a1 = 31 − 41 = 3 − 4 = −1
a2 = 32 − 42 = 9 − 16 = −7
3. How many eight-digit long strings of 0’s and 1’s are there having no more than
two 1’s?
S o l u t i o n. The set of strings that satisfy the requirement of this problem is the union of the
following three sets.
A = {8-strings without 1} ;
B = {8-strings with one 1} ;
C = {8-strings with two 1’s} .
By the formula for the number of permutations with given multiplicity,
|A| =
8!
8!
8!
, |B| =
, |C| =
,
8!0!
7!1!
6!2!
Clearly, A, B and C are disjoint. Therefore, the size of the union is
8!
8!
8!
+
+
= 1 + 8 + 4 · 7 = 37
8!0! 7!1! 6!2!
Another explanation to the same problem
is:
A
is
the
set
of
strings
of
length
8,
where
we
pick up 0 place for 1 for which there are 80 choices; B is the set of strings of length 8, where we
pick up 1 place for 1, for which there are 81 choices; for C, we pick up 2 places for 1’s for which
there are 82 choices. Therefore, all together, we have
8
8
8
+
+
= 1 + 8 + 28 = 37
0
1
2
choices.
4. A set of 60 people are surveyed. Among 60 people, there are 26 people who like
pizza, 32 people who like ice cream, and 30 people who like tofu. There are 14 people
who like both pizza and ice cream, seven people who like both pizza and tofu, two
people who like both ice cream and tofu, and two people who like all three. How
many dislike all three?
S o l u t i o n. Let
P : people who like pizza,
I : people who ice cream,
T : people who like tofu,
The following facts are given: There are 60 people surveyed, |P | = 26, |I| = 32, |T | = 30,
|P ∩ I| = 14, |P ∩ T | = 7, |I ∩ T | = 2, and |P ∩ I ∩ T | = 2. Thus, using the principle of
inclusion-exclusion, we have
|P ∪ I ∪ T | = 26 + 32 + 30 − 14 − 7 − 2 + 2 = 67
where, P ∪ I ∪ T is the set of people who like at least one of the three. Therefore, as this number
is larger than the number of people surveyed, the problem is incorrectly posed (some data given
are erroneous) and we cannot answer how many dislike all three.
Additional problem.
Find the coefficient of x4 in the expansion of
2+
x 10
.
4
S o l u t i o n. We observe that
x 10
x 10
= 210 1 + 3
4
2
10
By the Binomial Theorem, the coefficient of x4 in 1 + 2x3
is
2+
4
10
1
.
23
4
Therefore, the coefficient of of x4 in 1 is
4
10
1
210
10
10 · 9 · 8 · 7
5·3·7
105
2
= 12 ·
=
=
=
= 52.5.
3
4
2
2
4
4·4·3·2
2
2
10
(1)
Version B
1. A double star is a tree that has exactly two nodes that are not leaves. How many
(non-isomorphic) double stars are there on n nodes?
S o l u t i o n.
We can represent each double star by an unordered pair {x, y} where x is the number of
leaves adjacent to one of the two non-leaf nodes and y is the number of leaves adjacent to the
other:
Therefore, to compute the number of double stars we need to find the number of sets {x, y}
(note that {x, y} = {y, x}) such that x, y > 0 and x + y = n − 2. Alternatively, we need to find
the number of positive solutions of the Diophantine equation x+y = n−2 considering symmetry.
Let n be an odd number, say, n = 2k + 1 for some k. Then the number of solutions of
the above
equation (compare with the problem of delivering sweets to children) is
mentioned
2k+1−2−1
n−2−1
= 2k − 2. Due to symmetry, we have counted each pair {x, y} twice here
=
2−1
2−1
and actual number of double star graphs is k − 1.
Now,
nis even, n = 2k for some k. Then the number of solutions of the equation is
assume
n−2−1
2k−2−1
=
= 2k − 3. Among these solutions, there is one where x = y, other 2k − 4
2−1
2−1
pairs {x, y} are counted twice. Thus, the actual number of double stars is (2k − 4)/2 + 1 = k − 1.
We can conclude that the number of double stars on n nodes is equal to k − 1, where either
n = 2k or n = 2k + 1 depending on the parity of n.
2.
Solve the following recurrence relation (do not forget verification of the result):

 a0 = 0
a1 = 3

an − an−1 − 2an−2 = 0
for n > 2 :
S o l u t i o n.
Step 1 The associated characteristic equation is x2 − x − 2 = 0 and its two roots are x1 = 2
and x2 = −1.
Step 2 We note that (i) the nonhomogeneous part is 0 and (ii) all characteristic roots are
distinct. Thus, the general solution to the given recurrence equation is
an = A2n + B(−1)n .
Step 3 We use the initial conditions to solve the following equations for the unknown constants
A and B:
n=0: 0 =A+B
=⇒ A = 1, B = −1
n = 1 : 3 = 2A − B
Therefore, an = 2n + (−1)n+1 .
Step 4 For verification find from the equation a2 = a1 + 2a0 = 3 and check the result
a0 = 20 + (−1)1 = 1 − 1 = 0
a1 = 21 + (−1)2 = 2 + 1 = 3
a2 = 22 + (−1)3 = 4 − 1 = 3
3.
How many binary strings of length 10 have an even number of 1’s?
S o l u t i o n. The set of strings that satisfy the requirement of this problem is the union of the
following sets:
zero 1’s: 10
0 = 1 string
10·9
two 1’s: 10
2 = 2·1 = 45 strings
10·9·8·7
four 1’s: 10
4 = 4·3·2·1 = 210 strings
10
six 1’s: 10
=
6
4 = 210 strings
10
eight 1’s: 8 = 10
2 = 45 strings
ten 1’s: 10
10 = 1 string
So, summing up we get that the number of all binary strings of length 10 that have an even
number of 1’s is 2(1 + 45 + 210) = 512 strings. This is just a half of all binary strings of length
ten (210 = 1024 = 2 · 512).
4.
Let A, B, and C be sets with the following properties:
• |A| = 100, |B| = 50, and |C| = 48.
• The number of elements that belong to exactly one of the three sets is twice
the number that belong to exactly two of the sets.
• The number of elements that belong to exactly one of the three sets is three
times the number that belong to all of the sets.
How many elements belong to all three sets?
S o l u t i o n. Let
• a, b and c denote numbers of elements that belong exactly into the sets A, B and C respectively;
• s, t, u denote the numbers of elements that belong to exactly two of the sets;
• x denotes the number of elements that belong to all of the sets A, B and C.
The first property yields the following equations

 a + s + t + x = 100
b + s + u + x = 50

c + t + u + x = 48
Adding there three equations results in
(a + b + c) + 2(s + t + u) + 3x = 198
(2)
The second and third property gives
a + b + c = 2(s + t + u) = 3x.
Applying these equalities to the equation (2) gives
3x + 3x + 3x = 9x = 198.
So, x = 22, a + b + c = 3 · 22 = 66 and s + t + u = 66/2 = 33. Thus, the number of elements
that belong to all three sets is
(a + b + c) + (s + t + u) + x = 66 + 33 + 22 = 121.
Additional problem.
Find the fourth term in the expansion of
1
y −
4
4
10
.
S o l u t i o n. The k-th term of the expansion of (a + b)n is
n = 10, k = 4, a = y 4 , and b = − 14 . Thus, we get
n
k−1
an−k+1 bk−1 . For our case
3
4−1 10
1
10
1
4 7
4 10−4+1
=
(y ) −
=
(y )
−
4
3
4
4−1
10 · 9 · 8 28
1
=
−
=
y
2·3
64
=−
5 · 3 · 8 28
y =
64
=−
120 28
y =
64
=−
15 28
y
8