lOMoARcPSD|23198154
WTW 285 November Exam 2020 Solutions
Discrete structures (University of Pretoria)
Scan to open on Studocu
Studocu is not sponsored or endorsed by any college or university
Downloaded by Shayden Naidoo (
[email protected])
lOMoARcPSD|23198154
WTW 285 (Discrete Structures) Exam (23 November 2020) Section B: Part 1 of 3 (Solutions) Page 1 of 3
Section B: Part 1 of 3 (Solutions)
Question 1
1 1
Basis step: Let x be any basis element in M . Then x = for some prime number p. Now 0 <
p p
1
(because p > 0) and < 1 (because p > 1) hence 0 < x < 1 as required.
p
Induction hypothesis: Let a, b ∈ M and assume that
0 < a, b < 1. (⋆)
Induction step:
• 0 < ab (because a, b > 0 by (⋆)) and
ab < b (since a < 1 by (⋆))
< 1 (by (⋆))
i.e. 0 < ab < 1 .
• ab > 0 (shown above) and
a + b > a (since b > 0 by (⋆))
> 0 (by (⋆))
ab
hence > 0 (because ab > 0 and a + b > 0). Moreover,
a+b
ab < b (since a < 1 by (⋆))
< a + b (since a > 0 by (⋆))
ab ab
hence < 1 (because ab < a + b). Hence 0 < <1.
a+b a+b
Hence the property that 0 < x < 1 is preserved under the recursion operations of the set M .
Conclusion: By the principle of structural induction, 0 < x < 1 for each element x ∈ M .
Question 2
Method 1 (reducing the congruence equation to a Diophantine equation)
(x + 3)2 ≡ (x − 1)2 (mod 66) ⇐⇒ 66 | (x + 3)2 − (x − 1)2
⇐⇒ 66 | (8x + 8)
⇐⇒ 8x + 8 = 66y for some integer y
hence we seek all integer values of x for which there is an integer value of y such that
8x − 66y = −8 . (⋆)
lOMoARcPSD|23198154
WTW 285 (Discrete Structures) Exam (23 November 2020) Section B: Part 1 of 3 (Solutions) Page 2 of 3
Compute gcd(66, 8) using the Extended Euclidean Algorithm:
66 = 8 · 8 + 2
8 = 1·8+0
hence
gcd(66, 8) = 2 = 66 − 8 · 8 . (†)
Since gcd(8, −66) = gcd(66, 8) = 2 and 2 | (−8) then (⋆) has a solution (x, y) ∈ Z × Z.
Combine (⋆) and (†):
8x − 66y = −8 = −4 · 2 = −4(66 − 8 · 8) = 8(32) + 66(−4)
hence
8(x − 32) = 66(y − 4) . (‡)
Divide (‡) throughout by gcd(66, 8) = 2:
4(x − 32) = 33(y − 4) .
Hence 33 | 4(x − 32) but gcd(33, 4) = 1 so by Euclid’s Lemma, 33 | (x − 32), i.e.
x = 32 + 33t
for any integer t.
Method 2 (a more direct solution)
(x + 3)2 ≡ (x − 1)2 (mod 66) ⇐⇒ 66 | (x + 3)2 − (x − 1)2
⇐⇒ 66 | (8x + 8)
⇐⇒ 8(x + 1) = 66k for some integer k
⇐⇒ 4(x + 1) = 33k for some integer k (divide throughout by 2)
⇐⇒ 33 | 4(x + 1)
Hence the problem is equivalent to finding all integers x such that 33 | 4(x + 1). Since gcd(33, 4) = 1
then by Euclid’s Lemma, 33 | x + 1 hence x + 1 = 33t for some integer t, i.e.
x = −1 + 33t
for any integer t.
lOMoARcPSD|23198154
WTW 285 (Discrete Structures) Exam (23 November 2020) Section B: Part 1 of 3 (Solutions) Page 3 of 3
Question 3
(a)
K3,2 = 5
(b) Even though there are no routes using the permitted moves in a 1 × 1 chessboard, define K1,1 := 1
for the purposes of defining the recurrence relation. Let m and n be large integers. In an m × n
chessboard there are three choices for the first move:
(i) the king moves one square directly to the right (→): it then needs to move through an
(m−1)×n chessboard and there are Km−1,n possible routes through an (m−1)×n chessboard;
(ii) the king moves one square directly upwards (↑): it then needs to move through an m × (n − 1)
chessboard and there are Km,n−1 possible routes through an m × (n − 1) chessboard;
(iii) the king moves to the square that is above and to the right of its present square (ր): it then
needs to move through an (m − 1) × (n − 1) chessboard and there are Km−1,n−1 possible routes
through an (m − 1) × (n − 1) chessboard.
The quantities Km−1,n , Km,n−1 and Km−1,n−1 are all defined when m, n > 2. Hence
Km,n = Km−1,n + Km,n−1 + Km−1,n−1
when m, n > 2.
(c) The initial values will consist of Km,n when m = 1 or n = 1.
• For n > 2 there is only one route through a 1 × n chessboard: every move must be a move
directly upwards (↑) hence K1,n = 1.
• For m > 2 there is only one route through an m × 1 chessboard: every move must be a move
directly to the right (→) hence Km,1 = 1.
The initial values are therefore
K1,1 = 1 ,
K1,n = 1 for each n > 2 ,
Km,1 = 1 for each m > 2 .
lOMoARcPSD|23198154
WTW 285 (Discrete Structures) Exam (23 November 2020) Section B: Part 2 of 3 (Solutions) Page 1 of 2
Section B: Part 2 of 3 (Solutions)
Question 1
Question 2
(a) R is not transitive: 2R6 (because 2 | 6) and 6R3 (because 3 | 6) but it is not the case that 2R3
(because neither 2 | 3 nor 3 | 2).
(b) • P is reflexive: Let a ∈ N. Then (a + 1) | (a + 1) (because a + 1 = 1(a + 1)) hence aP a.
• P is antisymmetric: Let a, b ∈ N and suppose that aP b and bP a.
Then (a + 1) | (b + 1) and (b + 1) | (a + 1).
Hence b + 1 = α(a + 1) and a + 1 = β(b + 1) for some integers α and β.
Hence
a + 1 = β(b + 1) = β(α(a + 1)) = (αβ)(a + 1)
hence αβ = 1 which gives α = β = 1 or α = β = −1.
However, if α = β = −1 then a + 1 = −(b + 1) and since b ∈ N then b + 1 > 0 which gives
a + 1 < 0 hence a 6 0, a contradiction with the assumption that a ∈ N.
Hence it must be the case that α = β = 1 and so a + 1 = b + 1 hence a = b, as required.
• P is transitive: Let a, b, c ∈ N and suppose that aP b and bP c.
Then (a + 1) | (b + 1) and (b + 1) | (c + 1).
Hence b + 1 = α(a + 1) and c + 1 = β(b + 1) for some integers α and β.
Hence
c + 1 = β(b + 1) = β(α(a + 1)) = (αβ)(a + 1)
and since αβ is an integer then this means that (a + 1) | (c + 1) hence aP c, as required.
lOMoARcPSD|23198154
WTW 285 (Discrete Structures) Exam (23 November 2020) Section B: Part 2 of 3 (Solutions) Page 2 of 2
Question 3
(a) Let the degrees of the other four vertices in T be x, y, z and w, where, without loss of generality,
x 6 y 6 z 6 w.
Since T is a tree then |E(T )| = |V (T )| − 1 = 7 − 1 = 6.
By the Handshake Theorem,
the total degree of T = 2 |E(T )| = 2 × 6 = 12 .
Hence 2 + 2 + 1 + x + y + z + w = 12 so x + y + z + w = 12 − (2 + 2 + 1) = 7.
We therefore need to determine all tuples (x, y, z, w) with 1 6 x 6 y 6 z 6 w such that x + y +
z + w = 7. The possible tuples are:
(1, 1, 1, 4) ,
(1, 1, 2, 3) ,
(1, 2, 2, 2) .
Hence the possible degrees of the other four vertices in T are:
• 1, 1, 1 and 4;
• 1, 1, 2 and 3;
• 1, 2, 2 and 2.
In (b) it will be confirmed that such trees do actually exist.
(b) • Tree with vertices of degrees 1, 1, 1, 1, 2, 2 and 4:
• Tree with vertices of degrees 1, 1, 1, 2, 2, 2 and 3:
• Tree with vertices of degrees 1, 1, 2, 2, 2, 2 and 2:
lOMoARcPSD|23198154
WTW 285 (Discrete Structures) Exam (23 November 2020) Section B: Part 3 of 3 (Solutions) Page 1 of 2
Section B: Part 3 of 3 (Solutions)
Question 1
(a) (a | x)⋆ (b | x)⋆
(b)
Question 2
(a) • 0-equivalence classes of states: {s0 , s1 , s3 }, {s2 , s4 }
• 1-equivalence classes of states: {s0 , s1 }, {s3 }, {s2 , s4 }
• 2-equivalence classes of states: {s0 , s1 }, {s3 }, {s2 , s4 }
Hence the ⋆-equivalence classes of the states are {s0 , s1 }, {s3 } and {s2 , s4 }.
(b)
Question 3
Method 1 (method done in WTW 285)
Suppose (for a contradiction) that A = ({a, b}; S; s0 ; F ; N ) is a finite-state automaton that accepts L.
Consider the eventual-state function
N ⋆ : S × {a, b}⋆ → S.
Since S is finite and there are infinitely many strings of the form ak in {a, b}⋆ then there must exist
positive integers p and q with p 6= q, and a state si ∈ S, such that
N ⋆ (s0 , ap ) = si = N ⋆ (s0 , aq ).
lOMoARcPSD|23198154
WTW 285 (Discrete Structures) Exam (23 November 2020) Section B: Part 3 of 3 (Solutions) Page 2 of 2
Now
N ⋆ (s0 , aq b2p ) = N ⋆ (si , b2p ) (since N ⋆ (s0 , aq ) = si )
= N ⋆ (s0 , ap b2p ) (since N ⋆ (s0 , ap ) = si )
∈ F (since A accepts ap b2p )
hence A accepts the string aq b2p . However, aq b2p 6∈ L (because 2p 6= 2q), which contradicts the assumption
that A accepts L.
Hence there is no finite-state automaton that accepts L. By Kleene’s Theorem, L is not a regular
language.
Method 2 (using the Pumping Lemma)
Notation: Given any string α, let |α| denote the length of α.
Suppose (for a contradiction) that L is regular. Let the pumping length of L be p. Consider the string
ϕ := ap b2p .
Since |ϕ| = 3p > p then by the Pumping Lemma, ϕ can be written in the form
ϕ = αβγ
such that
(i) |αβ| 6 p, and
(ii) |β| > 1, and
(iii) αβ k γ ∈ L for each k ∈ N0 .
By (i) and (ii), α = ai and β = aj with for some whole numbers i and j with j > 1 and i + j 6 p, hence
γ = ap−i−j b2p . By (iii),
αβ 2 γ = ai a2j ap−i−j b2p = ap+j b2p ∈ L .
However, since 2(p + j) = 2p + 2j 6= 2p (because j > 1) then ap+j b2p 6∈ L, a contradiction. Hence L is
not regular.