Professional Documents
Culture Documents
03 Cis1103 Set Theory P3
03 Cis1103 Set Theory P3
03 Cis1103 Set Theory P3
DISCRETE STRUCTURES 1
Set Theory:
Computer Representation of Sets
Cartesian Product
Set Theory:
Note:
o However, if this is done, the operations of
computing the union, intersection, or difference of
two sets would be time-consuming, because each of
these operations would require a large amount of
searching elements.
COMPUTER REPRESENTATION OF SETS: METHOD 2
Tasks:
Determine the bit strings that represent the following:
a) the subset (V) of all odd integers in U,
b) the subset (W) of all even integers in U, and
c) the subset (X) of integers not exceeding 5 in U.
COMPUTER REPRESENTATION OF SETS: EXAMPLE
UNION & INTERSECTION:
Given:
Let U = {1,2,3,4,5,6,7,8,9,10}
Bit string for the set A = {1,2,3,4,5} = 1111100000
Bit string for the set B = {1,3,5,7,9} = 1010101010
Tasks:
Using the above bit strings,
a) find the bit string for the union (set C) of the given subsets;
b) find the bit string for the intersection (set D) of the given subsets.
COMPUTER REPRESENTATION OF SETS: EXAMPLE
COMPLEMENT:
Given:
Let U = {1,2,3,4,5,6,7,8,9,10}
Bit string for the set E = {1,3,5,7,9} = 1010101010
Task:
Determine the bit string for the complement of
the given subset E.
COMPUTER REPRESENTATION OF SETS: IMPORTANT NOTE
o otherwise use 0.
Set Theory:
Cartesian Product
CARTESIAN PRODUCT: INTRODUCTION
A x B = {(a, b) | a ∈ A and b ∈ B}
CARTESIAN PRODUCT: INTRODUCTION
Given:
A = {x, y, z}
B = {1, 2, 3}
Task:
Create a table showing the Cartesian Product
of A and B as a set of rows and a set of columns
respectively.
CARTESIAN PRODUCT: TUPLE & n-TUPLE
Tuple:
It is a finite ordered list (sequence) of elements.
n-Tuple:
It is a sequence (or ordered list) of n elements, where n is
a non-negative integer.
Note:
There is only one 0-tuple, an empty sequence, or empty
tuple, as it is referred to.
CARTESIAN PRODUCT: ORDERED PAIR
It is a pair of objects with an order associated with them.
If objects are represented by a and b, then we write the ordered pair
as (a, b).
Note (Equality of n-tuples):
Two ordered n-tuples are equal if and only if each
corresponding pair of their elements is equal.
In other words,
(a1, a2, . . . , an) = (b1, b2, . . . , bn)
if and only if ai = bi , for i = 1, 2, . . . , n.
CARTESIAN PRODUCT: ORDERED PAIR
In particular, 2-tuples are called ordered pairs.
The ordered pairs (a, b) and (c, d) are equal if and only if
a = c and b = d.
Example:
The ordered pair (1, 2) is not equal to the ordered pair (2, 1).
Note:
The ordered pairs (a, b) and (b, a) are not equal unless a = b.
A x B ≠ B x A unless A = B
CARTESIAN PRODUCT: EXAMPLE 2
Given:
A = {1, 2}
B = {a, b, c}
Task:
Find the Cartesian product A x B.
CARTESIAN PRODUCT: EXAMPLE 3
Given: o Note:
A = {1, 2}
B = {a, b, c} Therefore:
Task: AxB≠BxA
Given:
A = {0,1}
B = {1,2}
C = {0,1,2}
Task:
Find the Cartesian product A x B x C.
CARTESIAN PRODUCT: RENÉ DESCARTES
SELECT [select_list]
FROM [table1]
CROSS JOIN [table2]
Note:
o Some sources use semicolon after the SQL code
o Normally, semicolon is not used after the SQL code
PICTORIAL PRESENTATION OF CROSS JOIN
SQL CROSS JOIN
In CROSS JOIN,
o each row from the 1st table
o joins with all the rows
o of another table.
If:
o the 1st table contains x rows and
o the 2nd table contains y rows,
o the result set will x * y rows.
SQL CROSS JOIN: IMPORTANT NOTES
Joined every row from the first table (T1) with every
row from the second table (T2)
To get item name and item unit columns from foods table; company
name, company city columns from company table; and after a
CROSS JOINING with these mentioned tables, the following SQL
statement can be used:
To get item name and item unit columns from foods table; company
name, company city columns from company table; and after a
CROSS JOINING with these mentioned tables, the following SQL
statement can be used: