Page 32 - Discrete Structure II
P. 32
for ( i =1; i <= 6; i++)
for ( j =1; j < 5; i++)
for ( k =1; k <= 4; k++)
print (“Discrete II”);
Answer: 96
6 x 4 x 4 = 96
Generalization
Definition: Let A1, A2, …, An be n sets. An n-ary relation on A1, A2… An is a subset of A1 x A2 … x
An.
A1, A2, …, An are called domains.
The elements of the Cartesian product of 4 sets consist of 4-tuples (a, b, c, d),
The elements of the Cartesian product of 5 sets consist of 5-tuples (a, b, c, d, e),
The elements of the Cartesian product of n sets consist of n-tuples (a1, a2, a3, …, an).
Example
Consider the following sets:
I ={326895, 225867, 125369, 896731}
F={Mercedes, John, Paul, Kathy}
L = {Suarez, Doe, Gunter, Henry}
G ={3.4, 2.75, 2.98, 3.8}
1. How many elements are there in the Cartesian product I x F x L x G?
2. Give an example of a relation R (3 elements at least) on I, F, L and G.
solution:
1. How many elements are there in the Cartesian product I x F x L x G?
256 elements