0% found this document useful (0 votes)
15 views5 pages

Math for Computing Tutorial Solutions

Uploaded by

bill19012004
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)
15 views5 pages

Math for Computing Tutorial Solutions

Uploaded by

bill19012004
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

MATH2081 | MATH2328: Math for Computing

1
Lecturers: Dr Nguyen Hieu Thao & Dr Jeff Nijsse
Email: [Link]@[Link]

Tutorial Solutions: Sequences, Strings


and Relations
(2024C, Week 5)1

1 1
1. Compute wi , where wn = , ∀n ≥ 1.
P10
i=1 −
n n+1
Solution.
10     
X 1 1 1 1 1 1
wi = w1 + w2 + · · · + w10 = − + − + ··· −
i=1
1 2 2 3 10 11
     
1 1 1 1 1 1 1 1 1 10
= + − + − + ··· − −− =1− = .
1 2 2 3 3 10 10 11 11 11

2. Compute the following quantities concerning the strings α = baab, β = caaba, γ = bbab.

(a) αβ = baabcaaba (b) |βα| = 9 (c) ββγα = caabacaababbabbaab

3. List all strings over X = {0, 1} of length 3 or less.

Solution. λ (the null string), 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111.

4. List all substrings of the string babc.

Solution. λ, b, a, c, ba, ab, bc, bab, abc, babc.

5. Let X = {a, b}. Define a function from X ∗ to X ∗ as f (α) = αab. Is f one-to-one? Is f


onto? Justify your answers.

Solution. The function f is one-to-one since for any strings α 6= β, it holds that

f (α) = αab 6= βab = f (β).

The function f is not onto since there is no string α such that f (α) = a since every element
of range(f ) must end with ab.

1 Some of the content of this document is taken from the book [1].
3.3 Exercises
In Exercises 1–4, write the relation as a set of ordered pairs. 14.
1.
8840 Hammer
9921 Pliers
2 452 Paint
2207 Carpet
6. Consider the grammar generating the language
2. of all integers in Notes Week 5. Give a
derivation of the signed integer +2081. Sally Math
Ruth Physics
Solution. Sam Econ
< integer > ⇒ < signed integer >
3.
⇒ + < unsigned integer >
a 3 15.
⇒ + < digit >< unsigned
b integer1>
⇒ + < digit >< digit ><
b unsigned
4 integer >
c 1 unsigned integer >
⇒ + < digit >< digit >< digit >< 16.
⇒ + < digit >< digit >< digit >< digit >
4.
⇒ +2 < digit >< digit >< digit >
a a
⇒ +20 < digit >< digitb> b 17.
⇒ +208 < digit >

In Exercises 5–8, write the relation as a table.
⇒ +2081. Exer
5. R = {(a, 6), (b, 2), (a, 1), (c, 1)} defin
7. Write the relation R on {1, 2, 3, 4} given by (x, 6.
y) The iff x2 ≥
∈ Rrelation y {1, 2, 3, 4} defined by (x, y) ∈ R if x2 ≥ y
R on
18.
7. R = {(Roger, Music), (Pat, History), (Ben, Math),
as a table and draw its digraph. 20.
(Pat, PolySci)}
Solution. A table and a digraph of the relation is below.
8. The relation R from the set X of planets to the set Y of integers
defined by (x, y) ∈ R if x is in position y from the sun (nearest 21.
x 1 2 2 2 2 3 3 3 3 4 4the sun
4 being
4 in position 1, second nearest the sun being in
y 1 1 2 3 4 1 2 3 4 1 2position
3 2, 4 and so on) 22.
In Exercises 9–12, draw the digraph of the relation.
8. Draw the digraph of the relation 23.
9. The relation of Exercise 4 on {a, b, c}

R = {(1, 2), (2, 1), (3, 3), (1, 1), (2,10.2)}The relation R = {(1, 2), (2, 3), (3, 4), (4, 1)} on {1, 2, 3, 4} In E
11. The relation R = {(1, 2), (2, 1), (3, 3), (1, 1), (2, 2)} on the
X = {1, 2, 3} tran
on X = {1, 2, 3}.
12. The relation of Exercise 6 24.
Solution. The digraph is beside. In Exercises 13–16, write the relation as a set of ordered pairs. 25.
13. 26.
27.
a b
29.
9. Write the relation as a set of ordered pairs. 31.
32.
Solution. R = {(a, b), (a, c), (b, a), (b, d), (c, c), (c, d)}. 33.
35.
c d

10. Refer to the relation R on the set {1, 2, 3, 4, 5} given by (x, y) ∈ R iff 3 divides x − y. List
the elements of R−1 .

Solution. R−1 = {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (1, 4), (4, 1), (2, 5), (5, 2)}. ❦
3

11. Determine whether each relation defined on the set of positive integers is reflexive, sym-
metric, antisymmetric, transitive, a partial order.

(a) (x, y) ∈ R if 3 divides x − y. R is an equivalence relation.


(i) R is reflexive since for every set x, it holds that 3 divides x − x = 0.
(ii) R is symmetric since whenever 3 divides x − y, it holds that 3 divides y − x.
(iii) R is transitive since whenever 3 divides x − y and 3 divides y − z, it holds that 3
divides x − z.

(b) (x, y) ∈ R if x − y = 2. R has none of the considered properties. Justify this statement
for yourself.

12. Let X be a nonempty set. Define a relation on P(X), the power set of X, as (A, B) ∈ R if
A ⊆ B. Is this relation reflexive, symmetric, antisymmetric, transitive, or a partial order?

Solution. R is a partial order.

(i) R is reflexive since for every set A, it holds A ⊂ A.


(ii) R is not symmetric. For example, we have (∅, X) ∈ R since ∅ ⊂ X, but (X, ∅) ∈
/R
since X ∅.
(iii) R is antisymmetric since whenever A ⊂ B and B ⊂ A, it holds that A = B.
(iv) R is transitive since whenever A ⊂ B and B ⊂ C, it holds that A ⊂ C.

13. Let R1 = {(1, 1), (1, 2), (3, 4), (4, 2)} and R2 = {(1, 1), (2, 1), (3, 1), (4, 4), (2, 2)} be relations
on {1, 2, 3, 4}. List the elements of R1 ◦ R2 and R2 ◦ R1 .

Solution. Looking at all the ordered pairs from the first set to the last set, we have that

R1 ◦ R2 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2), (4, 2)}
R2 ◦ R1 = {(1, 1), (1, 2), (3, 4), (4, 1), (4, 2)} .

The digraphs of R1 ◦ R2 (R2 is computed first) and R2 ◦ R1 (R1 is computed first) are
respectively in figures (a) and (b) below.

(a) (b)
4

14. Give examples of relations on {1, 2, 3, 4} having the properties specified below.

(a) Reflexive, symmetric, and not transitive


Solution. R = {(1, 1), (2, 2), (3, 3), (4, 4), (1, 2), (2, 1), (2, 3), (3, 2)}. There are alterna-
tive solutions to this question.

(b) Not reflexive, not symmetric, and transitive


Solution. R = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 3), (1, 3)}. There are alternative solutions
to this question.

15. Determine whether the given relation is an equivalence relation on {1, 2, 3, 4, 5}. If the
relation is an equivalence relation, list the equivalence classes.

(a) R = {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (1, 3), (3, 1), (3, 4), (4, 3)}
Solution. It is not an equivalence relation since it is not transitive. Indeed, we have
(1, 3), (3, 4) ∈ R, but (1, 4) ∈
/ R.
(b) R = {(x, y) | x and y are both even or both odd}
Solution. It is an equivalence relation on {1, 2, 3, 4, 5}. There are two equivalence
classes: [1] = {1, 3, 5}, [2] = {2, 4}.

16. By listing ordered pairs, give an example of an equivalence relation on {1, 2, 3, 4, 5, 6} having
exactly four equivalence classes.
Solution. The following equivalence relation has exactly four equivalence classes:
R = {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (1, 2), (2, 1), (3, 4), (4, 3)}.
The equivalence classes are [1] = {1, 2}; [3] = {3, 4}; [5] = {5}; [6] = {6}. There are
alternative solutions to this question.

17. How many equivalence relations are there on the set {1, 2, 3}?

Solution. The reflexive property requires that every equivalence relation on {1, 2, 3} must
contain (1, 1), (2, 2) and (3, 3). Then symmetric pairs can gradually and respectively be
added in such a way that the transitive property is not broken to obtain more equivalence
relations. The challenge is that this process must be exhaustive. There are five equivalence
relations on {1, 2, 3} as follows:

R1 = {(1, 1), (2, 2), (3, 3)},


R2 = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1)},
R3 = {(1, 1), (2, 2), (3, 3), (1, 3), (3, 1)},
R4 = {(1, 1), (2, 2), (3, 3), (2, 3), (3, 2)},
R5 = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1), (1, 3), (3, 1), (2, 3), (3, 2)}.
5

18. Write the matrix of the relation


α β Σ δ
R = {(1, δ), (2, α), (2, Σ), (3, β), (3, Σ)}  
1 0 0 0 1
from X to Y relative to ordering of X: 1, 2, 3 and the 2 1 0 1 0
3 0 1 1 0
ordering of Y : α, β, Σ, δ.

19. Write the relation R, given by the following matrix, as a w x y z


 
w 1 0 1 0
set of ordered pairs. x0 0 0 0

y 1 0 1 0
Solution. R = {(w, w), (w, y), (y, w), (y, y), (z, z)}. z 0 0 0 1

References
1. Johnsonbaugh, R.: Discrete Mathematics - Eighth Edition. Pearson Education, New York
(2018).

Common questions

Powered by AI

The relation R has none of the specified properties. It is not reflexive as no pair (x, x) exists where x - x = 2. It is not symmetric because if x - y = 2, it does not imply y - x = 2. It is not antisymmetric because symmetry does not hold. Lastly, it is not transitive as there are no triples satisfying both x - y = 2 and y - z = 2 to conclude x - z = 2 .

The sequence evaluation is computed as follows: P_{10}^{i=1} wi = w1 + w2 + ... + w10 = (1/1 - 1/2) + (1/2 - 1/3) + ... + (1/10 - 1/11) = 1 - 1/11 = 10/11 after all intermediate terms cancel each other .

A relation being reflexive and symmetric does not necessarily make it transitive. A counter-example is a relation R on a set of integers defined by (x, y) ∈ R if 3 divides x - y. While R is reflexive and symmetric, it is not necessarily transitive for all x, y, z as 3 dividing both x - y and y - z does not imply it divides x - z without additional justification .

The function f is one-to-one (injective) because for any strings α and β where α ≠ β, it holds that f(α) = αab ≠ βab = f(β). However, f is not onto (surjective) since there is no string α such that f(α) = a; every element in the range of f must end with 'ab' .

Elements of the inverse relation R-1 are {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (1, 4), (4, 1), (2, 5), (5, 2)}, as each pair satisfies the condition that 3 divides x - y .

The relation is a partial order because: (i) it is reflexive as A ⊆ A for every set A, (ii) it is not symmetric as, for example, (∅, X) ∈ R does not imply (X, ∅) ∈ R, and (iii) it is antisymmetric because if A ⊆ B and B ⊆ A, then A = B holds, and (iv) it is transitive since if A ⊆ B and B ⊆ C, then A ⊆ C .

The strings of length 3 or less formed over the set X = {0, 1} are λ (the null string), 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, and 111 .

R is reflexive as every set A is a subset of itself. It's antisymmetric because if A ⊆ B and B ⊆ A, then A = B. It's also transitive; if A ⊆ B and B ⊆ C, then A ⊆ C, thus R satisfies all these properties, making it a partial order .

Starting from <integer> expression: <integer> ⇒ <signed integer> ⇒ +<unsigned integer> ⇒ + <digit><unsigned integer> ⇒ + <digit><digit><unsigned integer> ⇒ + <digit><digit><digit><unsigned integer> ⇒ + <digit><digit><digit><digit> ⇒ +2<digit><digit><digit> ⇒ +20<digit><digit> ⇒ +208<digit> ⇒ +2081, whereby each step involves substituting based on the grammar rules .

The matrix relative to the ordering X: 1, 2, 3 and Y: α, β, Σ, δ is represented as: \n α β Σ δ \n1 0 0 0 1 \n2 1 0 1 0 \n3 0 1 1 0, reflecting the presence or absence (1 or 0) of each corresponding pair in the relation .

You might also like