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

Republic of the Philippines

CAMARINES NORTE STATE COLLEGE


F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

OUTLINE OF LEARNING TOPICS TIME ALLOCATION


A. Sets and Notations Week 1 - 4 [Prelim]
A.1 Sets and Subsets
A.2 Set-Builder Notation
A.3 Venn Diagrams
A.4 Set Operations
A.5 Computer Representation of Sets
A.6 Pseudocodes
A.7 Ordered Pairs

INTENDED LEARNING OUTCOMES (ILOs)


At the end of the topic, students should be able to
 Perform the operations associated with sets, sequences, algorithm and pseudocodes.

INSTRUCTIONS TO THE LEARNERS


This learning material serves as a reflection among one of the flexible learning strategies that complement
the outcomes-based education approach. This material contains the essential discussions for the specified
topic together with a learning activity in order to achieve the indicated intended learning outcomes.

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

INSTITUTE OF COMPUTER STUDIES

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.

A. Sets and Notations


Introduction
In this learning material the basic tools of discrete mathematics will be introduced. We start with sets,
subsets, and their operations, notions that many of you are already familiar with. Next we deal with ways of
counting the elements in a set. We present pseudocode, a language for describing many of the algorithms
as other important concepts will be introduced later.

A.1 Sets and Subsets


A set is any well-defined collection of objects called the elements or members of the set. For example,
the set of all wooden chairs, the set of all one-legged black birds, or the set of real numbers between zero
and one. Almost all mathematical objects are first of all sets, regardless of any additional properties they may
possess. Thus set theory is, in a sense, the foundation on which virtually all of mathematics is constructed.
In spite of this, set theory (at least the informal brand we need) is quite easy to learn and use.
• A set is a group of “objects”
– People in a class: { Abigail, Wilson, Chris }
– Classes offered by a department: { CS 101, CS 202, … }
– Colors of a rainbow: { red, orange, yellow, green, blue, purple }
– States of matter { solid, liquid, gas, plasma }
– Municipality in the Cams. Norte: { Daet, Basud, Labo, … }
– Sets can contain non-related elements: { 3, a, pula, Moroso }
• Although a set can contain (almost) anything, we will most often use sets of numbers
– All positive numbers less than or equal to 5: {1, 2, 3, 4, 5}
– A few selected real numbers: { 2.1, π, 0, -6.32, e }

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

INSTITUTE OF COMPUTER STUDIES

– Not always feasible for large or infinite sets


• Can use an ellipsis (…): B = {0, 1, 2, 3, …}
– Can cause confusion. Consider the set C = {3, 5, 7 …}. What comes next?
– If the set is all odd integers greater than 2, it is 9
– If the set is all prime numbers greater than 2, it is 11
• Can use set-builder notation
– D = {x | x is prime and x > 2}
– E = {x | x is odd and x > 2}
– The vertical bar means “such that”
– Thus, set D is read (in English) as: “all elements x such that x is prime and x is greater than
2”
• A set is said to “contain” the various “members” or “elements” that make up the set
– If an element a is a member of (or an element of) a set S, we use then notation a  S
• 4  {1, 2, 3, 4}
– If an element is not a member of (or an element of) a set S, we use the notation a  S
• 7  {1, 2, 3, 4}
• Virginia  {1, 2, 3, 4}

Often Used Sets


• ℕ = {0, 1, 2, 3, …} is the set of natural numbers
• Z = {…, -2, -1, 0, 1, 2, …} is the set of integers
• Z+ = {1, 2, 3, …} is the set of positive integers (a.k.a whole numbers)
– Note that people disagree on the exact definitions of whole numbers and natural numbers
• Q = {p/q | p  Z, q  Z, q ≠ 0} is the set of rational numbers
– Any number that can be expressed as a fraction of two integers (where the bottom one is not
zero)
• R is the set of real numbers

The Universal Set
• U is the universal set – the set of all of elements (or the “universe”) from which given any set is drawn
– For the set {-2, 0.4, 2}, U would be the real numbers
– For the set {0, 1, 2}, U could be the natural numbers (zero and up), the integers, the rational
numbers, or the real numbers, depending on the context
– For the set of the students in this class, U would be all the students in the University (or
perhaps all the people in the world)
– For the set of the vowels of the alphabet, U would be all the letters of the alphabet
– To differentiate U from U (which is a set operation), the universal set is written in a different
font (and in bold and italics)

Exercise Set No. 1


1. List the elements of each of the following sets.
a. The odd natural numbers less than 16.
Set A = ___________________________________________________.

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

INSTITUTE OF COMPUTER STUDIES

b. The squares of the first 5 even natural numbers.


Set A = ___________________________________________________.
c. The integers between -6 and 6.
Set A = ___________________________________________________.
d. The integers less than 2.
Set A = ___________________________________________________.
e. The integers greater than -2.
Set A = ___________________________________________________.

2. Let A = {1, 2, 4, a, b, e}. Answer each of the following as true or false.


a) 2 ∈ A _____________
b) 3 ∈ A _____________
c) C ∈ A _____________
d) ∅ ∈ A _____________
e) ∅ ∉ A _____________
f) A ∈ A _____________

A.2 Set-Builder Notation

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.

Let's look at an example of how to describe a set by means of set-builder notation.

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

INSTITUTE OF COMPUTER STUDIES

Example:

The elements of set A are listed as follows: A = {..., – 9, – 6, –3, 0, 3, 6, 9, ...}.

Describe this set by means of set-builder notation.


1. First, let x represent the elements of the set.
2. Since the elements of this set belong to set ℤ, it becomes the universe and we can write:

x∈ℤ

3. Since each element of this set is a multiple of 3, we write:

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.

The result is A = {x ∈ ℤ|x is a multiple of 3}.

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".

Exercise Set No. 2


1. Use everyday language to describe the following sets given in set-builder notation.
Page 6 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines

INSTITUTE OF COMPUTER STUDIES

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} ______________________________________________________
________________________________________________________________________________

2. Describe the following sets by using set-builder notation.


a) A = {1, 3, 5, 7, 9, ...} _____________________________________________________________
b) B = {0, 1, 2, 3} __________________________________________________________________
c) C = {–27, – 8, –1, 0, 1, 8, 27} _______________________________________________________
d) D = {1, 3, 5, 15} _________________________________________________________________
e) E = {..., 0, 7, 14, 21, 28, ...} ________________________________________________________

3. Describe the following sets by listing their elements.


a) D = {x ∈ ℤ |x is an even number} _______________________________________________________
b) E = {x ∈ ℕ |x ≥ – 2} _________________________________________________________________
c) F = {x ∈ ℕ |x is a multiple of 100} ______________________________________________________
d) G = {x ∈ ℤ |x is a divisor of 50} ________________________________________________________
e) J = {x ∈ℤ |–2 < x < 6} _______________________________________________________________

A.3 Venn Diagrams


The third way of describing a set is to draw a closed figure (usually a circle) containing points that represent
all the elements belonging to the set. When we do this, we are describing a set using a Venn diagram. This
technique is most often used to represent finite sets or sets of numbers that we are very familiar with, such
as natural numbers, integers and rational numbers.

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

INSTITUTE OF COMPUTER STUDIES

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.

Let A = {0, 1, 2, 3} and B = {3, 4, 5}.

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

Exercise Set No. 3

1. Describe the following sets using a Venn diagram.

a) A = {0, 1, 4, 5, 8} b) B = {1, 4, 6, 8}

c) C = {x ∈ |–2 < x < 3 and x is even} d) D = {x ∈ |2 < x < 4}

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

The Empty Set


• If a set has zero elements, it is called the empty (or null) set
– Written using the symbol 
– Thus,  = { }  VERY IMPORTANT
– If you get confused about the empty set in a problem, try replacing  by { }
• As the empty set is a set, it can be a element of other sets
– { , 1, 2, 3, x } is a valid set
• Note that  ≠ {  }
– The first is a set of zero elements
– The second is a set of 1 element (that one element being the empty set)
• Replace  by { }, and you get: { } ≠ { { } }
• It’s easier to see that they are not equal that way

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}

• Note that any set is a subset of itself!


– Given set S = {2, 4, 6}, since all the elements of S are elements of S, S is a subset of itself
– This is kind of like saying 5 is less than or equal to 5
– Thus, for any set S, S  S
• The empty set is a subset of all sets (including itself!)
– Recall that all sets are subsets of themselves
Page 12 of 37
IT 104 – Discrete Mathematics
Republic of the Philippines
CAMARINES NORTE STATE COLLEGE
F. Pimentel Avenue, Brgy. 2, Daet, Camarines Norte – 4600, Philippines

INSTITUTE OF COMPUTER STUDIES

• All sets are subsets of the universal set


• A horrible way to define a subset:
– x ( xA  xB )
– English translation: for all possible values of x, (meaning for all possible elements of a set), if
x is an element of A, then x is an element of B
– This type of notation will be gone over later

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

A.4 Set Operations


If A and B are sets, we define their union as the set consisting of all elements that belong to A or B and
denote it by A U B. thus

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

INSTITUTE OF COMPUTER STUDIES

A U B = {x | x  A or x  B}.

Observe that x  A U B if x  A or x  B or x belongs to both A and 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.

Figure 1.4a 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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

Exercise Set No. 4


Let U = {a, b, c, d, e, f, g h, k}, A = {a, b, c, g}, B = {d, e, f, g}, C = {a, c, f}, and D = {f, h, k}.

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

INSTITUTE OF COMPUTER STUDIES

(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

4. Let A, B, and C be finite sets with |A| = 6, |B| = 8, |C| = 6, |A U B U C| = 11, |A ∩ B| = 3, |A ∩ C| = 2,


and |B ∩ C| = 5. Find |A ∩ B ∩ C|.

5. In a survey of 260 college students, the following data were obtained:


64 had taken a mathematics course,
94 had taken a BSIT course,
58 had taken a business course,
28 had taken both a mathematics and a business course,
26 had taken both a mathematics and a BSIT course,
22 had taken both a BSIT course and a business course, and
14 had taken all three types of courses.
(a) How many students were surveyed who had taken none of the three types of courses?
(b) Of the students surveyed, how many had taken only a BSIT course?

A.5 Computer Representation of Sets

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

• Assume that U is finite (and reasonable!)


– Let U be the alphabet
– Each bit represents whether the element in U is in the set
• The vowels in the alphabet:
abcdefghijklmnopqrstuvwxyz
10001000100000100000100000
• The consonants in the alphabet:
abcdefghijklmnopqrstuvwxyz
01110111011111011111011111
• Consider the union of these two sets:
10001000100000100000100000
01110111011111011111011111
11111111111111111111111111
• Consider the intersection of these two sets:
10001000100000100000100000
01110111011111011111011111
00000000000000000000000000

Exercise Set No. 5

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.

(a) 11 1100 1111 (b) 01 0111 1000 (c) 10 0000 0001

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

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

INSTITUTE OF COMPUTER STUDIES

Exercise Set No. 6

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

X[1]Y[1] + X[2]Y[2] + X[3]Y[3]

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

INSTITUTE OF COMPUTER STUDIES

A.7 Ordered Pairs

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.

Cartesian Product of Sets

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.

Consider two sets A and B where set A had x


coordinates and set B had y coordinates.

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

INSTITUTE OF COMPUTER STUDIES

The two points formed will be

In this combinations, the first element is


from set A and second is from set B

Each such combinations is an ordered


pair

All possible distinct combinations are


called the Cartesian product of Set A
and set B.

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.

Cartesian product of P and Q is denoted as

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

INSTITUTE OF COMPUTER STUDIES

If set P or set Q is an empty or null set,


then the Cartesian product is a null set.

Consider this two sets P and Q

The Cartesian product of P and Q is

Now, let’s mark these points on the


Cartesian plane and join them. The
figure is formed will be

Consider the same sets P and Q, and


find the Cartesian product QxP this time

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

INSTITUTE OF COMPUTER STUDIES

Now, let’s mark these points on the


Cartesian plane and join them.

The figures so formed from ordered


Pairs of PxQ and QxP are different

The ordered pair (1, 2) is not equal


to ordered pair (2,1)

We can conclude that PxQ not equal


to QxP

Another example:

Consider two sets P and Q

The Cartesian product of P and Q

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

INSTITUTE OF COMPUTER STUDIES

The Cartesian product of Q and P

Here, the ordered pairs are not identical,


we can conclude that PxQ not equal
to QxP

Revision

All possible distinct combinations are


called the Cartesian product of set A
and set B

If set P or set Q is an empty or null set,


then the Cartesian product is a null set

Number of Ordered Pairs

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.

Solved Examples for You

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

INSTITUTE OF COMPUTER STUDIES

Question 2: What is the Cartesian product used for?

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.

Question 3: What is a Cartesian product example?

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)}

Question 4: What is the Cartesian product of Sets?

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.

Question 5: Who invented the Cartesian product?

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.

Exercise Set No. 7

Direction: Answer the following. Show your solutions.

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

INSTITUTE OF COMPUTER STUDIES

4. Given M=(0,1,2) and N=(1,2,3). Find (N−M)×(N∩M).

5. Let A and B be two sets such that A×B={(a,1),(b,3),(a,3),(b,1),(a,2),(b,2)}, then A = ? and B = ?

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

You might also like