Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Discrete Structure Assignment no.

Dr. A. Q. khan Institute of Computer Science & Information


Technology

DISCRETE STRUCTURE

ASSIGNMENT NO. 2
Submitted to:
Sir Zafar Iqbal

Name:
Esha Baig

Registration no:
UET-18F-BSCE-18

Department:
BSCE

Semester:
4

Date:
st
1 June, 2020

Day:
Monday

1|Page
Discrete Structure Assignment no. 4

Question no. 1
Let A = {a, b, c}, B = {x, y}, and C = {0, 1}. Find
a) A × B × C. b) C × B × A.
c) C × A × B. d) B × B × B.

a) A × B × C.
Solution:-
Using the definition of the Cartesian product, we know that A x B x C are ordered triplets of
any combination of the elements in each set (in the same order as the sets in the Cartesian
product).
A x B x C.={(a,x , 0), (a, x ,1), (a, y , 0), (a,y , 1), (b, x , 0), (b, x , 1), (b, y,0),(b, y,1), (c, x ,0), (c,
x , 1), (c, y, 0), (c, y, 1)}

b) C × B × A
Solution:-
Using the definition of the Cartesian product, we know that C x B x A are ordered triplets of
any combination of the elements in each set (in the same order as the sets in the Cartesian
product).
C x B x A = { (0, x, a), (0, x, b), (0, x, c), (0, y, a), (0, y, b), (0, y, c), (1,x,a), (1,x,b),(1,x,c),(1,y,a),
(1,y, b), (1,y,c)}

c) C × A × B.
Solution:-
Using the definition of the Cartesian product, we know that C x A x B are ordered triplets of
any combination of the elements in each set (in the same order as the sets in the Cartesian
product).
C x A x B = {(0, a, x), (0,a, y), (0, b, x), (0, b, y), (0,c, x), (0, c, y), (1,a, x), (1,a, y), (1, b,x),(1,b,
y), (1, c, s),(1,c,y)}

d) B × B × B.
Solution:-
Using the definition of the Cartesian product, we know that B x B x B are ordered triplets of
any combination of the elements in each set (in the same order as the sets in the Cartesian
product).
B x B x B = {(x, x, x),(x, x, y), (x, y, x), (x, y, y), (y, x, x), (y, x, 0, (y, y, x),(y,y,y)}

Question no. 2
Let A, B, and C be sets. Show that

Solution:-
We have,

𝐀 ∪ (𝐁 ∩ 𝐂) = 𝐀 ∩ (𝐁 ∩ 𝐂) by the first De Morgan law


= 𝐀 ∩ (𝐁 ∪ 𝐂) by the second De Morgan law
= (𝐁 ∪ 𝐂) ∩ 𝐀 by the commutative law for intersections
= (𝐂 ∪ 𝐁) ∩ 𝐀 by the commutative law for unions.

2|Page
Discrete Structure Assignment no. 4

Question no. 3
Use a membership table to show that A∩(B ∪C)= (A∩B)∪(A∩C).
Solution:-

A B C 𝐁∪𝐂 A∩ (𝐁 ∪ 𝐂) A∩ 𝐁 A∩ 𝐂 (A∩ 𝐁) ∪ (𝐀 ∩ 𝐂)

1 1 1 1 1 1 1 1
1 1 0 1 1 1 0 1
1 0 1 1 1 0 1 1
1 0 0 0 0 0 0 0
0 1 𝟏 1 0 0 0 0
0 1 0 1 0 0 0 0
0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0

Question no. 4
Let A = {0, 2, 4, 6, 8}, B = {0, 1, 2, 3, 4}, and C = {0, 3, 6, 9}. What are A ∪ B ∪ C and A ∩ B ∩ C
?
Solution:-
The set 𝐀 ∪ 𝐁 ∪ 𝐂 contains those elements in at least one of A, B, and C.
Hence, 𝐀 ∪ 𝐁 ∪ 𝐂 = { 𝟎, 𝟏, 𝟐, 𝟑, 𝟒, 𝟔, 𝟖, 𝟗}.
The set 𝐀 ∩ 𝐁 ∩ 𝐂 contains those elements in all three of A, B, and C.
Thus, 𝐀 ∩ 𝐁 ∩ 𝐂 = {𝟎}.
We can also consider unions and intersections of an arbitrary number of sets.
We introduce these definitions.

Question no. 5
The bit strings for the sets {1, 2, 3, 4, 5} and {1, 3, 5, 7, 9} are 11 1110 0000 and 10 1010
1010, respectively. Use bit strings to find the union and intersection of these sets.

Solution:-
The bit string for the union of these sets is
11 1110 0000 ∨ 10 1010 1010 = 11 1110 1010, which corresponds to the set {1,2,3,4,5,7,9}.

The bit string for the intersection of these sets is


11 1110 0000 ∧ 10 1010 1010 = 10 1010 0000, which corresponds to the set {1,3,5}.

Question no. 6
Let f1 and f2 be functions from R to R such that f1 (x) = x2 and f2 (x) = x − x2. What are the
functions f1 + f2 and f1 f2?

Solution:-
From the definition of the sum and product of functions, it follows that
(𝐟𝟏 + 𝐟𝟐 )(𝐱) = 𝐟𝟏 (𝐱) + 𝐟𝟐 (𝐱) = 𝐱 𝟐 + (𝐱 − 𝐱 𝟐 ) = 𝐱

3|Page
Discrete Structure Assignment no. 4

and
(𝐟𝟏 𝐟𝟐 )(𝐱) = 𝐱 𝟐 (𝐱 − 𝐱 𝟐 ) = 𝐱 𝟑 − 𝐱 𝟒
When f is a function from A to B, the image of a subset of A can also be defined.

Question no. 7
Let f and g be the functions from the set of integers to the set of integers defined by f (x) =
2x + 3 and g(x) = 3x + 2. What is the composition of f and g? What is the composition of g
and f ? 147

Solution:-
Both the compositions 𝐟 𝐨 𝐠 and 𝐠 𝐨 𝐟 are defined. Moreover,
(𝐟 𝐨 𝐠)(𝐱) = 𝐟(𝐠(𝐱)) = 𝐟(𝟑𝐱 + 𝟐) = 𝟐(𝟑𝐱 + 𝟐) + 𝟑 = 𝟔𝐱 + 𝟕
and
(𝐠 𝐨 𝐟)(𝐱) = 𝐠(𝐟(𝐱)) = 𝐠(𝟐𝐱 + 𝟑) = 𝟑(𝟐𝐱 + 𝟑) + 𝟐 = 𝟔𝐱 + 𝟏𝟏

Question no. 8
Let {an} be a sequence that satisfies the recurrence relation an = an−1 + 3 for n = 1, 2, 3, . . .
, and suppose that a0 = 2. What are a1, a2, and a3?158

Solution:-
We see from the recurrence relation that a1 = a0 +3=2+3=5. It then follows that a2 =5+3=8
and a3 =8+3=11.

Question no. 9
Let {an} be a sequence that satisfies the recurrence relation an = an−1 − an−2 for n = 2, 3, 4,
. . . , and suppose that a0 = 3 and a1 = 5. What are a2 and a3?

Solution:-
We see from the recurrence relation that a2 = a1−a0 =5−3=2 and a3 = a2 − a1 =2−5=−3. We
can find a4, a5, and each successive term in a similar way

Question no. 10 164


What is the value of ∑𝟓𝐣=𝟏 𝐣𝟐

Solution:-
We have
𝟓
∑ 𝐣 𝟐 = 𝟏 𝟐 + 𝟐𝟐 + 𝟑𝟐 + 𝟒𝟐 + 𝟓𝟐
𝐣=𝟏
= 𝟏 + 𝟒 + 𝟗 + 𝟏𝟔 + 𝟐𝟓
= 𝟓𝟓

Question no. 11
What is the value of the following summation? ∑𝟐𝐢=𝟏 ∑𝟑𝐣=𝟏 𝐢𝐣

Solution:-
∑𝟐𝐢=𝟏 ∑𝟑𝐣=𝟏 𝐢𝐣 = ∑𝟐𝐢=𝟏(𝐢 + 𝟐𝐢 + 𝟑𝐢)

4|Page
Discrete Structure Assignment no. 4

= ∑𝟐𝐢=𝟏 𝟔𝐢
= 𝟔 + 𝟏𝟐
= 𝟏𝟖

Question no. 12

a) A  B
𝐀
Solution:-

𝟏 𝟎 𝟏 𝟎 𝟏 𝟏
[
𝐀𝐁 = 𝟏 𝟏 𝟎]  [𝟏 𝟎 𝟏]
𝟎 𝟎 𝟏 𝟏 𝟎 𝟏

(𝟏 𝟎 ) (𝟎 𝟏) (𝟏 𝟏)


𝐀𝐁 = [ (𝟏  𝟏) (𝟏 𝟎) (𝟎 𝟏) ]
(𝟎  𝟎) (𝟎 𝟎) (𝟏 𝟏)

𝟏 𝟏 𝟏
𝐀𝐁 = [𝟏 𝟏 𝟏]
𝟎 𝟎 𝟏

b) A  B

Solution:-

𝟏 𝟎 𝟏 𝟎 𝟏 𝟏
𝐀𝐁 = [𝟏 𝟏 𝟎 ]  [ 𝟏 𝟎 𝟏]
𝟎 𝟎 𝟏 𝟏 𝟎 𝟏

(𝟏𝟎)(𝟎𝟏)(𝟏𝟏) (𝟏𝟏)(𝟎𝟎)(𝟏𝟎) (𝟏𝟏)(𝟎𝟏)(𝟏𝟏)


𝐀𝐁 = [(𝟏𝟎)(𝟏𝟏)(𝟎𝟏) (𝟏𝟏)(𝟏𝟎)(𝟎𝟎) (𝟏𝟏)(𝟏𝟏)(𝟎𝟏) ]
(𝟎𝟎)(𝟎𝟏)(𝟏𝟏) (𝟎𝟏)(𝟎𝟎)(𝟏𝟎) (𝟎𝟏)(𝟎𝟏)(𝟏𝟏)

𝟏 𝟏 𝟏
𝐀𝐁 = [𝟏 𝟏 𝟎]
𝟏 𝟎 𝟏

5|Page
Discrete Structure Assignment no. 4

c) A ⊙ B

Solution:-

𝟏 𝟎 𝟏 𝟎 𝟏 𝟏
𝐀 ⊙ 𝐁 = [𝟏 𝟏 𝟎 ] ⊙ [𝟏 𝟎 𝟏]
𝟎 𝟎 𝟏 𝟏 𝟎 𝟏

(𝟏𝟎)(𝟎𝟏)(𝟏𝟏) (𝟏𝟏)(𝟎𝟎)(𝟏𝟎) (𝟏𝟏)(𝟎𝟏)(𝟏𝟏)


𝐀 ⊙ 𝐁 = [(𝟏𝟎)(𝟏𝟏)(𝟎𝟏) (𝟏𝟏)(𝟏𝟎)(𝟎𝟎) (𝟏𝟏)(𝟏𝟏)(𝟎𝟏) ]
(𝟎𝟎)(𝟎𝟏)(𝟏𝟏) (𝟎𝟏)(𝟎𝟎)(𝟏𝟎) (𝟎𝟏)(𝟎𝟏)(𝟏𝟏)

𝟏 𝟏 𝟏
𝐀 ⊙ 𝐁 = [𝟏 𝟏 𝟏]
𝟏 𝟎 𝟏

Question no. 13
Find the Boolean product of A and B, where

Solution:-
Let suppose

The Boolean product A⊙ B is given by

𝟏 𝟎
𝟏 𝟏 𝟎
𝐀 ⊙ 𝐁 = [𝟎 𝟏 ] ⊙ [ ]
𝟎 𝟏 𝟏
𝟏 𝟎

(𝟏𝟏)(𝟎𝟎) (𝟏𝟏)(𝟎𝟏) (𝟏𝟎)(𝟎𝟏)


𝐀 ⊙ 𝐁 = [(𝟎𝟏)(𝟏𝟎) (𝟎𝟏)(𝟏𝟏) (𝟎𝟎)(𝟏𝟏) ]
(𝟏𝟏)(𝟎𝟎) (𝟏𝟏)(𝟎𝟏) (𝟏𝟎)(𝟎𝟏)

𝟏𝟎 𝟏𝟎 𝟎𝟎


𝐀 ⊙ 𝐁 = [𝟎𝟎 𝟎𝟏 𝟎𝟏 ]
𝟏𝟎 𝟏𝟎 𝟎𝟎

𝟏 𝟏 𝟎
𝐀 ⊙ 𝐁 = [𝟎 𝟏 𝟏]
𝟏 𝟏 𝟎

6|Page
Discrete Structure Assignment no. 4

We can also define the Boolean powers of a square zero–one matrix. These powers will
be used in our subsequent studies of paths in graphs, which are used to model such things
as communications paths in computer networks.

Question no. 14
Find the join and meet of the zero–one matrices

Solution:-

We find that the join of A and B is

𝟏 𝟎 𝟏 𝟎 𝟏 𝟎
𝐀𝐁 = [ ][ ]
𝟎 𝟏 𝟎 𝟏 𝟏 𝟎

𝟏 𝟎 𝟎 𝟏 𝟏 𝟎
𝐀𝐁 = [ ]
𝟎𝟏 𝟏 𝟏 𝟎 𝟎

𝟏 𝟏 𝟏
𝐀𝐁 =[ ]
𝟏 𝟏 𝟎

The meet of A and B is

𝟏 𝟎 𝟏 𝟎 𝟏 𝟎
A B = [ ] [ ]
𝟎 𝟏 𝟎 𝟏 𝟏 𝟎

𝟏𝟎 𝟎𝟏 𝟏 𝟎
A B = [ ]
𝟎 𝟏 𝟏 𝟏 𝟎 𝟎

𝟎 𝟎 𝟎
A B = [ ]
𝟏 𝟏 𝟎

We now define the Boolean product of two matrices.

Question no. 15
Let A = {1, 2, 3} and B = {1, 2, 3, 4}. The relations R1 = {(1, 1), (2, 2), (3, 3)} and R2 = {(1, 1),
(1, 2), (1, 3), (1, 4)}, Find
a) R1 ∪ R2 b) R1 ∩ R2
c) R1 − R2. d) R2 − R1 579
a) R1 ∪ R2
Solution:-

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

b) R1 ∩ R2
Solution:-

R1∩R2 ={ (1,1)}

7|Page
Discrete Structure Assignment no. 4

c) R1 − R2.
Solution:-
R1−R2 ={ (2,2),(3,3)}

d) R2 − R1
Solution:-
R2 −R1 ={ (1,2),(1,3),(1,4)}.

Question no. 16
Suppose that the relations R1 and R2 on a set A are represented by the matrices

What are the matrices representing R1 ∪ R2 and R1 ∩ R2?


Solution:-
The matrices of these relations are:
MR1∪ MR2:

1 0 1 1 0 1
MR1∪ MR2 = MR1 MR2 = [1 0 0 ]  [0 1 1]
0 1 0 1 0 0

11 00 11


MR1∪ MR2 = [10 01 01 ]
01 10 00
𝟏 𝟎 𝟏
MR1∪ MR2 = [𝟏 𝟏 𝟏 ]
𝟏 𝟏 𝟎
MR1 ∩ MR2:

1 0 1 1 0 1
MR1∩ MR2 = MR1 MR2 = [1 0 0 ]  [ 0 1 1]
0 1 0 1 0 0

(11)(00)(11) (10)(01)(10) (11)(01)(10)


MR1∩ MR2 =[(11)(00)(01) (10)(01)(00) (11)(01)(00) ]
(01)(10)(01) (01)(11)(00) (01)(11)(00)

𝟏 𝟎 𝟏
MR1∩ MR2 = [𝟏 𝟎 𝟏]
𝟎 𝟏 𝟏

Question # 17
Find the matrix representing the relations S o R, where the matrices representing R and S
are

8|Page
Discrete Structure Assignment no. 4

Solution:-
The matrix for S◦R is
MS o R = MR ⊙ MS.

(𝟏𝟎)(𝟎𝟎)(𝟏𝟏) (𝟏𝟏)(𝟎𝟎)(𝟏𝟎) (𝟏𝟎)(𝟎𝟏)(𝟏𝟏)


MR ⊙ MS = [(𝟏𝟎)(𝟏𝟎)(𝟎𝟏) (𝟏𝟏)(𝟏𝟎)(𝟏𝟎) (𝟏𝟎)(𝟏𝟏)(𝟎𝟏) ]
(𝟎𝟎)(𝟎𝟎)(𝟎𝟏) (𝟎𝟏)(𝟎𝟎)(𝟎𝟎) (𝟎𝟎)(𝟎𝟏)(𝟎𝟏)

𝟏 𝟏 𝟏
M R ⊙ M S = [𝟎 𝟏 𝟏]
𝟎 𝟎 𝟎

The matrix representing the composite of two relations can be used to find the matrix for MRn
.
In particular, MRn = M[n] R ,

Question # 18 Let A={1,2,3,4}. Define a relation R on A as R={(1,1), (1,2), (2,3), (3,2), (4,4)}.
Find the transitive closure of R
Solution:-

Question # 19 Let A = {1, 2, 3, 4} & define relations R1, R2, R3 and R4 on A by the directed
graphs:
R1 = {(1, 1), (1, 3), (2, 4), (3, 1), (4,2)}
R2 = {(1, 1), (2, 2), (3, 3), (4, 4)}
R3 = {(2, 2), (2, 3), (3, 4)}
R4 = {(1, 1), (2, 2), (3, 3), (4, 3), (4, 4)}
Solution:-
A={1,2,3,4}.
R={(1,1), (1,2), (2,3), (3,2), (4,4)}

A relation R on A as equivalence relation.


 (1,1) R.
 (2,2)  R. Transitive
 (3,3)  R.
 (4,4)  R.

 (1,2).
 (2,1). Symmetric.
 (3,1).
 (1,3).

9|Page
Discrete Structure Assignment no. 4

Now,
Rt = {(1,1), (1,2), (1,3), (2,2), (2,3), (3,2), (3,3), (4,4)}.

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


Directed graph:

2 4

R2 = {(1, 1), (2, 2), (3, 3), (4, 4)}

Directed graph:

2 4

10 | P a g e
Discrete Structure Assignment no. 4

R3 = {(2, 2), (2, 3), (3, 4)}


Directed graph:

3 4

R4 = {(1, 1), (2, 2), (3, 3), (4, 3), (4, 4)}

Directed graph:

2 4

11 | P a g e
Discrete Structure Assignment no. 4

Question no. 20

Find the first five terms of the sequence and determine if it is arithmetic.
an = 1 + (n – 1)4

Solution:-

Formula of Arithmetic Sequence:

an = a1+(n-1)d

According to formulas we know that


a1 = 1
d= 4.
a1:
We check the value of a1 is true or not.
We find a1 when n=1.
a1 = 1+(1-1)4.
a1 = 1+(0)4.
a1 = 1+0.
a1 = 1.
a2:
We find a2 when n=2.
a2 = 1+(2-1)4.
a2 = 1+(2-1)4.
a2 = 1+4.
a2 = 5.
a3:
We find a3 when n=3.
a3 = 1+(3-1)4.
a3 = 1+(3-1)4.
a3 = 1+2(4).
a3 = 1+8.
a3 = 9.
a4:
We find a4 when n=4.
a4 = 1+(4-1)4.
a4 = 1+(4-1)4.
a4 = 1+3(4).
a4 = 1+12.
a4 = 13.
a5:
We find a5 when n=5.
a5 = 1+(5-1)4.

12 | P a g e
Discrete Structure Assignment no. 4

a5 = 1+(5-1)4.
a5 = 1+4(4).
a5 = 1+16.
a5 = 17.

The first five terms of an = 1 + (n – 1)4 are 1,5,9,13,17

THE END

13 | P a g e

You might also like