Page 31 - Discrete Structure II
P. 31
A binary relation from A to B is a subset of A x B
Example 2:
Consider the following A ={a, b} B = { a, c, d}, C = {1, 2}
Find A x B x C and C x A x B
Solution
A x B X C consists of all triplets (x, y, z ) such that x is an element of A , y is an element of B and z is an
element of C.
A x B X C ={(a, a, 1), (a, c, 1), (a, d, 1), (b, a, 1), (b, c, 1), (b, d, 1), (a, a, 2), (a, c, 2), (a, d, 2), (b, a, 2), (b, c,
2), (b, d, 2)
Exercises:
a. Determine how many times “Discrete II” is printed
for ( i =1; i < 5; i++)
for ( j =1; j <= 5; i++)
for ( k =1; k < 4; k++)
print (“Discrete II”);
Answer: 60 times
for ( i =1; i < 5; i++) A={1, 2, 3, 4}
for ( j =1; j <= 5; i++) B = { 1, 2, 3, 4, 5}
for ( k =1; k < 4; k++) C = {1, 2, 3}
|A x B x C | = 4 x 5 x 3 = 60
b. Determine how many times “Discrete” is printed