Professional Documents
Culture Documents
IT 104 Learning Materials No. 1
IT 104 Learning Materials No. 1
Page 1 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
IT 104-DISCRETE MATHEMATICS
Edgar Bryan B. Nicart, MIT
Asst. Prof. II
Contact Details
Contact Number: 09298788329
E-mail Address: edgarbryann@yahoo.com
Web Address: https://www.facebook.com/edgarbryann/
Consultation Schedule
W/ 8:00am – 9:00am/ 1st Semester, SY 2020-2021
In addition, students will undergo pre-test and post-test short-examination. The pre-test questionnaires will
be given at the start of each rating period (Prelims, Midterms, Finals) while the post-test questionnaires will
be given at the end of each rating period. The results of the assessment will serve as one of the key indicators
that determine the effectiveness of this learning material. Thus, exemplifying honesty and rectitude in this
particular undertaking are highly appreciated and commendable.
Page 2 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Always keep connected and updated with announcements and relevant information concerning this course.
Lastly, do not hesitate to ask for assistance and raise your concerns to your instructor / professor.
Set Properties
• Order does not matter
– We often write them in order because it is easier for humans to understand it that way
– {1, 2, 3, 4, 5} is equivalent to {3, 5, 2, 4, 1}
– Sets are notated with curly brackets
– Sets do not have duplicate elements
• Consider the set of vowels in the alphabet.
• It makes no sense to list them as {a, a, a, e, i, o, o, o, o, o, u}
• What we really want is just {a, e, i, o, u}
– Consider the list of students in this class
• Again, it does not make sense to list somebody twice
– Note that a list is like a set, but order does matter and duplicate elements are allowed
• We won’t be studying lists much in this class
Specifying a Set
• Sets are usually represented by a capital letter (A, B, S, etc.)
• Elements are usually represented by an italic lower-case letter (a, x, y, etc.)
• Easiest way to specify a set is to list all the elements: A = {1, 2, 3, 4, 5}
Page 3 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 4 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
A second way of describing a set is to state one or more characteristics possessed by all the elements of this
set and by no element that does not. When we do this, we are describing a set by means of set-builder
notation.
The characteristics common to all the elements of the set must be specific enough so that only one
interpretation is possible. We should then be able to identify these elements, and only these elements without
having to list them. This representation is more concise.
Since we need not list any other elements belonging to the set, a lowercase letter (usually x, y or z) will be
used to designate all the elements of the set.
Page 5 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Example:
x∈ℤ
x is a multiple of 3.
4. These two mathematical expressions can be linked by the vertical line (|) which means "such that."
5. We then write the name of the set and put the two mathematical expressions in brackets.
This mathematical expression means that A is the set of all the x elements belonging to the set of integers
such that x is a multiple of 3.
We have seen that when we describe a set using set-builder notation, we can use mathematical language
and symbols to state all the characteristics of the set without listing a single element of the set.
To express order relations between numbers, we use the following mathematical symbols:
< for "less than";
> for "greater than";
= for "equal to";
≤ for "less than or equal to";
≥ for "greater than or equal to".
a) A = {x ∈ ℤ |x > – 3} _______________________________________________________________
________________________________________________________________________________
b) B = {x ∈ ℤ |x < 7 and x is an odd number} _____________________________________________
________________________________________________________________________________
c) C = {x ∈ Q |x is a divisor of 0} ______________________________________________________
________________________________________________________________________________
Venn Diagrams
• Represents sets graphically
– The box represents the universal set
– Circles represent the set(s)
• Consider set S, which is the set of all vowels in the alphabet
• The individual elements are usually not written in a Venn diagram
Example:
Page 7 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
That's all there is to it! We now have a Venn diagram of set A, and we can easily list its elements by simply
naming the elements shown in the circle.
Most of the problems we will encounter will involve more than one set.
If the universe U = {0, 1, 2, 3, 4, 5, 6, 7}, we can describe these three sets using a Venn diagram. The
universe is represented by a rectangle. Since sets A and B and the elements of these sets belong to the
universe U, they will also be shown in the rectangle.
Example:
Page 8 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 9 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
a) A = {0, 1, 4, 5, 8} b) B = {1, 4, 6, 8}
2. Describe the sets shown in the Venn diagrams below, first by listing their elements and then by means of
set-builder notation.
Page 10 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 11 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Sets of Sets
• Sets can contain other sets
– S = { {1}, {2}, {3} }
– T = { {1}, {{2}}, {{{3}}} }
– V = { {{1}, {{2}}}, {{{3}}}, { {1}, {{2}}, {{{3}}} } }
• V has only 3 elements!
• Note that 1 ≠ {1} ≠ {{1}} ≠ {{{1}}}
– They are all different
Set Equality
• Two sets are equal if they have the same elements
– {1, 2, 3, 4, 5} = {5, 4, 3, 2, 1}
• Remember that order does not matter!
– {1, 2, 3, 2, 4, 3, 2, 1} = {4, 3, 2, 1}
• Remember that duplicate elements do not matter!
• Two sets are not equal if they do not have the same elements
– {1, 2, 3, 4, 5} ≠ {1, 2, 3, 4}
Subsets
• If all the elements of a set S are also elements of a set T, then S is a subset of T
– For example, if S = {2, 4, 6} and T = {1, 2, 3, 4, 5, 6, 7}, then S is a subset of T
– This is specified by S T
• Or by {2, 4, 6} {1, 2, 3, 4, 5, 6, 7}
• If S is not a subset of T, it is written as such: S T
– For example, {1, 2, 8} {1, 2, 3, 4, 5, 6, 7}
Proper Subsets
• If S is a subset of T, and S is not equal to T, then S is a proper subset of T
– Let T = {0, 1, 2, 3, 4, 5}
– If S = {1, 2, 3}, S is not equal to T, and S is a subset of T
– A proper subset is written as S T
– Let R = {0, 1, 2, 3, 4, 5}. R is equal to T, and thus is a subset (but not a proper subset) or T
• Can be written as: R T and R T (or just R = T)
– Let Q = {4, 5, 6}. Q is neither a subset or T nor a proper subset of T
• The difference between “subset” and “proper subset” is like the difference between “less than or equal
to” and “less than” for numbers
• The empty set is a proper subset of all sets other than the empty set (as it is equal to the empty set)
Set Cardinality
• The cardinality of a set is the number of elements in a set
– Written as |A|
• Examples
– Let R = {1, 2, 3, 4, 5}. Then |R| = 5
– || = 0
– Let S = {, {a}, {b}, {a, b}}. Then |S| = 4
• This is the same notation used for vector length in geometry
• A set with one element is sometimes called a singleton set
Power Sets
• Given the set S = {0, 1}. What are all the possible subsets of S?
– They are: (as it is a subset of all sets), {0}, {1}, and {0, 1}
– The power set of S (written as P(S)) is the set of all the subsets of S
– P(S) = { , {0}, {1}, {0,1} }
• Note that |S| = 2 and |P(S)| = 4
• Let T = {0, 1, 2}. The P(T) = { , {0}, {1}, {2}, {0,1}, {0,2}, {1,2}, {0,1,2} }
• Note that |T| = 3 and |P(T)| = 8
• P() = { }
• Note that || = 0 and |P()| = 1
• If a set has n elements, then the power set will have 2n elements
Page 13 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
A U B = {x | x A or x B}.
Example 1:
Let A = {a, b, c, e, f} and B = {b, d, r, s}. Find A U B.
Solution: Since A U B consists of all the elements that belong to either A or B, A U B = {a, b, c, d, e, f, r, s}.
We can illustrate the union of two sets with a Venn diagram as follows. If A and B are the sets given
in Figure 1.4a, then A U B is the set represented by the shaded region in Figure 1.4b.
If A and B are sets, we define their intersection as the set consisting of all elements that belong to
both A and B and denote it by A ∩ B. Thus A ∩ B = {x | x A and x B}.
Example 2:
Let A = {a, b, c, e, f}, B = {b, e, f, r, s}, and C = {a, t, u, v}. Find A ∩ B, A ∩ C, and B ∩ C.
Solution: The elements b, e, and f are the only ones that belong to both A and B, so A ∩ B = {b, e, f}.
Similarly, A ∩ C = {a}. There are no elements that belong to both B and C, so B ∩ C = { }.
Two sets that have no common elements, such as B and C in Example 2, are called disjoint sets.
We can illustrate the intersection of two sets by a Venn diagram as follows. If a and B are the sets
given in Figure 1.5(a), then A ∩ B is the set represented by the shaded region in Figure 1.5(b). Figure 1.6
illustrates a Venn diagram for two disjoint sets.
The operations of union and intersection can be defined for three or more sets in an obvious manner.
A U B U C = {x | x A or x B or x C}
and
A ∩ B ∩ C = {x | x A and x B and x C}
Page 14 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 15 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 16 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 17 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 18 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 19 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
1. Compute
2. Compute
(a) A U B U C
(b) A ∩ B ∩ C
(c) A ∩ (B U C)
Page 20 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
(d) (A U B) ∩ C
Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9}, A = {1, 2, 4, 6, 8}, B = {2, 4, 5, 9}, C = {x | x is a positive integer and x 2 ≤ 16},
and D = {7, 8}.
3. Compute
Page 21 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 22 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
1. Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, and the ordering of elements U has the elements in increasing
order; i.e., ai = i. what bit strings represent the subset of all odd integers in U, the subset of all even
integers in U, and the subset of integers not exceeding 5 in U?
2. We have seen that the bit string for the set {1, 3, 5, 7, 9} (with universal set {1, 2, 3, 4, 5, 6, 7, 8, 9,
10}) is 10 1010 1010. What is the bit string for the complement of this set?
3. 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.
4. Using the universal set U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, find the set specified by each of the following
bit strings.
Page 23 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
A.6 Pseudocodes
Page 24 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 25 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 26 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 27 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 28 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 29 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Direction: Write the steps in pseudocode needed to perform the task described.
1. In a certain country, the tax structure is as follows. An income of $30,000 or more results in $6000
tax, an income of $20,000 to $30,000 pays $2500 tax, and an income of less than $20,000 pays a
10% tax. Write a function TAX that accepts a variable INCOME and outputs the tax appropriate to
that income.
2. Lex X1, X2,…,XN be a given set of numbers. Write the steps needed to compute the sum and average
of the numbers.
3. Suppose that the array X consists of the real numbers X[1], X[2], X[3] and the array Y consists of the
real numbers Y[1], Y[2], Y[3]. Write an algorithm in pseudocode to compute
4. Let A[1], A[2], A[3] be the coefficient of a quadratic equation ax2 + bx + c = 0 (that is, A[1] contains
a, A[2] contains b, and A[3] contains c). Write an algorithm that computes the roots R1 and R2 of
the equation if they are real and distinct. If the roots are real and equal, the value should be
assigned to R1 and a message printed. If the roots are not real, an appropriate message should be
printed and computation halted. You may use the function SQRT (which returns the square root of
any nonnegative number X).
Direction: Describe what is accomplished by the pseudocode. Unspecified inputs or variables X and Y
represent rational numbers, while N and M represent integers.
5. SUBROUTINE MAX(X,Y;Z)
1. Z ← X
2. IF (X < Y) THEN
a. Z ← Y
3. RETURN
END OF SUBROUTINE MAX
Page 30 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Before getting familiar with this term, let us understand what does Cartesian mean. Remember the terms used
when plotting a graph paper like axes (x-axis, y-axis), origin etc. For example, (2, 3) depicts that the value on
the x-plane (axis) is 2 and that for y is 3 which is not the same as (3, 2).
The way of representation is fixed that the value of the x coordinate will come first and then that for y (ordered
way). Cartesian product means the product of the elements say x and y in an ordered way.
The Cartesian products of sets mean the product of two non-empty sets in an ordered way. Or, in other words,
the collection of all ordered pairs obtained by the product of two non-empty sets. An ordered pair means that two
elements are taken from each set.
For two non-empty sets (say A & B), the first element of the pair is from one set A and the second element is
taken from the second set B. The collection of all such pairs gives us a Cartesian product.
The Cartesian product of two non-empty sets A and B is denoted by A × B. Also, known as the cross-product
or the product set of A and B. The ordered pairs (a, b) is such that a ∈ A and b ∈ B. So, A × B = {(a,b): a ∈ A,
b ∈ B}. For example, Consider two non-empty sets A = {a1, a2, a3} and B = {b1, b2, b3}
Cartesian product A×B = {(a1,b1), (a1,b2), (a1,b3), ( a2,b1), (a2,b2),(a2,b3), (a3,b1), (a3,b2), (a3,b3)}.
It is interesting to know that (a1,b1) will be different from (b1,a1). If either of the two sets is a null set, i.e., either A
= Φ or B = Φ, then, A × B = Φ i.e., A × B will also be a null set.
Page 31 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
In mathematical terms, set of all ordered pairs of elements from two non-empty sets P and Q is the Cartesian
product and is denoted by: PxQ.
Page 32 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Page 33 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Another example:
Page 34 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Revision
For two non-empty sets, A and B. If the number of elements of A is h i.e., n(A) = h & that of B is k i.e., n(B) = k,
then the number of ordered pairs in Cartesian product will be n(A × B) = n(A) × n(B) = hk.
Question 1: Let P & Q be two sets such that n(P) = 4 and n(Q) = 2. If in the Cartesian product we have
(m,1), (n,-1), (x,1), (y, -1). Find P and Q, where m, n, x, and y are all distinct.
Answer : P = set of first elements = {m, n, x, y} and Q = set of second elements = {1, -1}
Page 35 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
Answer: A Cartesian product in computing is basically the exact same as in mathematics. It will be applicable
to matrix applications. In SQL it explains a bug where you join two tables wrongly and get many records from
one table being connected to each of the records of the other, instead of the expected one.
Answer: As we know that the Cartesian product is the multiplication of two sets to make the set of all ordered
pairs. The first element of the ordered pair will be belonging to the first set and the second pair belong the
second set. For instance, Suppose, A = {cow, horse} B = {egg, juice} then, A×B = {(cow, egg), (horse, juice),
(cow, juice), (horse, egg)}
Answer: The Cartesian product of sets refers to the product of two non-empty sets in an ordered way. Or, in
other words, the assortment of all ordered pairs attained by the product of two non-empty sets. An ordered pair
basically means that two elements are taken from each set.
Answer: René Descartes invented the Cartesian product. It derives the name from the same person. René
formulated analytic geometry which helped in the origination of this concept which we further generalize in
terms of direct product.
1. Let A={−3,−1},B={1,3} and C={3,5}. Find A×B, and enter the value of number of elements of it.
2. Let A and B be two sets such that A×B consists of 6 elements. If three elements of A×B are
{(1,4),(2,6),(3,6)}.Find A×B and B×A
3. (x,y) and (p,q) are two ordered pairs. Find the values of x and p, if (3x−1,9)=(11,p+2).
Page 36 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines
References:
Serge Dugas and Louise Allard (2007). MTH-4109-1, Sets, Relations and Functions. Société de formation à distance
des commissions scolaires du Québec, ISBN 978-2-89493-287-2.
B. Kolman, R. Busby, and S. Ross. Discrete Mathematical Structures. Prentice Hall 3rd Edition, 1996.
Page 37 of 37
IT 104 – Discrete Mathematics