COMP232 - Mathematics for Computer Science

COMP232 - Mathematics for Computer Science
Tutorial 10
Ali Moallemi
moa [email protected]
Iraj Hedayati
h [email protected]
Concordia University, Winter 2016
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
1 / 20
Table of Contents
1
9.3 Representing Relations
Exercise 3
Exercise 9
Exercise 10
Exercise 13
Exercise 15
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
2 / 20
Exercise 3
List the ordered pairs in the relations on {1, 2, 3} corresponding to these
matrices (where the rows and columns correspond to the integers listed in
increasing order).
a)


1 0 1
0 1 0
1 0 1
Answer: R = {(1, 1), (1, 3), (2, 2), (3, 1), (3, 3)}
b)


0 1 0
0 1 0
0 1 0
Answer: R = {(1, 2), (2, 2), (3, 2)}
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
3 / 20
Exercise 3 Cont...
List the ordered pairs in the relations on {1, 2, 3} corresponding to these
matrices (where the rows and columns correspond to the integers listed in
increasing order).
c)


1 1 1
1 0 1
1 1 1
Answer: R = {(1, 1), (1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2), (3, 3)}
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
4 / 20
Exercise 9
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 100} consisting of the first 100 positive integers have if R
is
a) {(a, b)|a > b}?
Answer:

0
0

0

R = .
 ..

0
0
1 1 ...
0 1 ...
0 0 ...
.. ..
..
. .
.
0 0 ...
0 0 ...

1 1
1 1

1 1

.. .. 
. .

0 1
0 0
# nonzero elements: 99 + 98 + 97 + · · · + 1 =
Ali Moallemi, Iraj Hedayati
99×100
2
= 4950
COMP232 - Mathematics for Computer Science
5 / 20
Exercise 9 Cont...
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 100} consisting of the first 100 positive integers have if R
is
b) {(a, b)|a 6= b}?
Answer:

0
1

1

R = .
 ..

1
1
1 1 ...
0 1 ...
1 0 ...
.. ..
..
. .
.
1 1 ...
1 1 ...

1 1
1 1

1 1

.. .. 
. .

0 1
1 0
# nonzero elements: 99 × 100 = 9900 or 100 × 100 − 100 = 9900
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
6 / 20
Exercise 9 Cont...
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 100} consisting of the first 100 positive integers have if R
is
c) {(a, b)|a = b + 1}?
Answer:

0
1

0

R = .
 ..

0
0
0 0 ...
0 0 ...
1 0 ...
.. ..
..
. .
.
0 0 ...
0 0 ...

0 0
0 0

0 0

.. .. 
. .

0 0
1 0
# nonzero elements: 99
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
7 / 20
Exercise 9 Cont...
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 100} consisting of the first 100 positive integers have if R
is
d) {(a, b)|a = 1}?
Answer:

1
0

0

R = .
 ..

0
0
1 1 ...
0 0 ...
0 0 ...
.. ..
..
. .
.
0 0 ...
0 0 ...

1 1
0 0

0 0

.. .. 
. .

0 0
0 0
# nonzero elements: 100
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
8 / 20
Exercise 9 Cont...
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 100} consisting of the first 100 positive integers have if R
is
e) {(a, b)|ab = 1}?
Answer:

1
0

0

R = .
 ..

0
0
0 0 ...
0 0 ...
0 0 ...
.. ..
..
. .
.
0 0 ...
0 0 ...

0 0
0 0

0 0

.. .. 
. .

0 0
0 0
# nonzero elements: 1
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
9 / 20
Exercise 10
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 1000} consisting of the first 1000 positive integers have if
R is
a) {(a, b)|a ≤ b}?
Answer:

1
0

0

R = .
 ..

0
0
1 1 ...
1 1 ...
0 1 ...
.. ..
..
. .
.
0 0 ...
0 0 ...

1 1
1 1

1 1

.. .. 
. .

1 1
0 1
# nonzero elements: 1000 + 999 + 998 · · · + 1 =
Ali Moallemi, Iraj Hedayati
1000×1001
2
COMP232 - Mathematics for Computer Science
= 500500
10 / 20
Exercise 10 Cont...
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 1000} consisting of the first 1000 positive integers have if
R is
b) {(a, b)|a = b ± 1}?
Answer:

0
1

0

R = .
 ..

0
0
1 0 ...
0 1 ...
1 0 ...
.. ..
..
. .
.
0 0 ...
0 0 ...

0 0
0 0

0 0

.. .. 
. .

0 1
1 0
# nonzero elements: 2 × 999 + 1 + 1 = 1998
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
11 / 20
Exercise 10 Cont...
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 1000} consisting of the first 1000 positive integers have if
R is
c) {(a, b)|a + b = 1000}?
Answer:

0
0

0

R = .
 ..

1
0
0 ...
0 ...
0 ...
..
..
.
.
0 ...
0 ...

0 1 0
1 0 0

0 0 0

.. .. .. 
. . .

0 0 0
0 0 0
# nonzero elements: 999
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
12 / 20
Exercise 10 Cont...
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 1000} consisting of the first 1000 positive integers have if
R is
d) {(a, b)|a + b ≤ 1001}?
Answer:

1
1

1

R = .
 ..

1
1
1 1 ...
1 1 ...
1 1 ...
.. ..
..
. .
.
1 0 ...
0 0 ...

1 1
1 0

0 0

.. .. 
. .

0 0
0 0
# nonzero elements: 1000 + 999 + 998 · · · + 1 =
Ali Moallemi, Iraj Hedayati
1000×1001
2
COMP232 - Mathematics for Computer Science
= 500500
13 / 20
Exercise 10 Cont...
How many nonzero entries does the matrix representing the relation R on
A = {1, 2, 3, ..., 1000} consisting of the first 1000 positive integers have if
R is
e) {(a, b)|a 6= 0}?
Answer:

1 1 1 ...
1 1 1 . . .


R = 1 1 1 . . .
 .. .. ..
..
. . .
.
1 1 1 ...

1 1
1 1

1 1

.. .. 
. .
1 1
# nonzero elements: 1000 × 1000 = 1000000
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
14 / 20
Exercise 13
Let R be the relation represented by the matrix


0 1 1
MR = 1 1 0
1 0 1
a) Find the matrix representing R −1 ?
Answer:


0 1 1
MR −1 = 1 1 0
1 0 1
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
15 / 20
Exercise 13 Cont...
Let R be the relation represented by the matrix


0 1 1
MR = 1 1 0
1 0 1
b) Find the matrix representing R?
Answer:


1 0 0
MR = 0 0 1
0 1 0
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
16 / 20
Exercise 13 Cont...
Let R be the relation represented by the matrix


0 1 1
MR = 1 1 0
1 0 1
c) Find the matrix representing R 2 ?
Answer:


1 1 1
MR 2 = 1 1 1
1 1 1
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
17 / 20
Exercise 15
Let R be the relation represented by the matrix


0 1 0
MR = 0 0 1
1 1 0
a) Find the matrix representing R 2 ?
Answer:

 
 

0 1 0
0 1 0
0 0 1
MR 2 = 0 0 1 × 0 0 1 = 1 1 0
1 1 0
1 1 0
0 1 1
Ali Moallemi, Iraj Hedayati
COMP232 - Mathematics for Computer Science
18 / 20
Exercise 15 Cont...
Let R be the relation represented by the matrix


0 1 0
MR = 0 0 1
1 1 0
b) Find the matrix representing
Answer:

0

MR 3 = MR 2 · MR = 1
0
Ali Moallemi, Iraj Hedayati
R 3?
 
 

0 1
0 1 0
1 1 0
1 0 × 0 0 1 = 0 1 1
1 1
1 1 0
1 1 1
COMP232 - Mathematics for Computer Science
19 / 20
Exercise 15 Cont...
Let R be the relation represented by the matrix


0 1 0
MR = 0 0 1
1 1 0
c) Find the matrix representing
Answer:

1

MR 4 = MR 3 · MR = 0
1
Ali Moallemi, Iraj Hedayati
R 4?
 
 

1 0
0 1 0
0 1 1
1 1 × 0 0 1 = 1 1 1
1 1
1 1 0
1 1 1
COMP232 - Mathematics for Computer Science
20 / 20