Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Mid II Lecture

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

CSE106 Discrete Mathematics

Credit Hours: 3 + 0 = 3
Prerequisite: CSE103 Structured Programming

Instructor:
Md. Mozammel Huq Azad Khan, PhD
Professor, CSE Dept., East West University

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 1


Text book:
Kenneth H. Rosen, Discrete Mathematics and Its
Applications with Combinatorics and Graph Theory, 7th
Edition, Tata McGraw-Hill Publishing Company Limited,
New Delhi, 2015.

Midterm II

Link: http://bit.ly/2Nn8BLk
Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 2
Chapter 2
Basic Structures: Sets, Functions, Sequences, and Sums

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 3


2.1 Sets

Definition 1: A set is an unordered collection of objects.

Definition 2:
The objects in a set are called the elements, or members, of the set.
We write a  A to denote that a is an element of the set A.
The notation a  A denotes that a is not a member of the set A.

A set is described by listing all the members of the set.

Example 1: The set V of all vowels in the English alphabet can be written as V = {a, e, i, o, u}.

Example 2: The set O of odd positive integers less than 10 can be expressed by O = {1, 3, 5, 7, 9}.

Example 3: {a, 2, Fred, New Jersey} is the set containing the four elements a, 2, Fred, and New Jersey.

Example 4: The set of positive integers less than 100 can be denoted by {1, 2, 3, , 99}.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 4


Another way of describing a set is to use set builder notation. We characterize all those elements in the set by
stating the property or properties they must have to be members.

The set O of all odd positive integers less that 10 can be written as
O = {xx is an odd positive integer less than 10}

These sets play an important role in discrete mathematics:


N = (0, 1, 2, 3, }, the set of natural numbers
Z = {, 2, 1, 0, 1, 2, }, the set of integers
Z+ = {1, 2, 3, }, the set of positive integers
Q = {p/q  p  Z, q  Z, q  0}, the set of rational numbers
R, the set of real numbers

Definition 3: Two sets are equal if and only if they have the same elements. That is, if A and B are sets, then A
and B are equal if and only if x(x  A  x  B). We write A = B if A and B are equal sets.

Example 6: The sets {1, 3, 5} and {3, 5, 1} are equal.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 5


Sets can be represented graphically using Venn diagrams.
In Venn diagrams the universal set U, which contains all the objects under consideration, is represented by a
rectangle.
Inside this rectangle, circles are used to represent sets.
Sometimes points are used to represent the particular elements of the set.

Example 7: Draw a Venn diagram that represents V, the set of vowels in the English alphabet.

Solution:
Universal set U is the set of the 26 letters of the English alphabet.

U
a e
u V i
o

Figure 1 Venn Diagram for the Set of Vowels.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 6


There is a special set that has no elements. This set is called the empty set, or null set, and is denoted by .
The empty set can also be denoted by { }.

A set with one element is called a singleton set.

Definition 4: The set A is said to be a subset of B if and only if every element of A is also an element of B. We
use the notation A  B to indicate that A is a subset of the set B.
We see that A  B if and only if x(x  A  x  B) is true.

Example 8:
The set of all odd positive integers less than 10 is a subset of the set of all positive integers less than 10.
The set of rational numbers is a subset of the set of real numbers.

Theorem 1: For any set S, (i)   S and (ii) S  S.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 7


When we wish to emphasize that a set A is a subset of the set B but A  B, we write A  B and say that A is a
proper subset of B.
A is a proper subset of B if x(x  A  x  B)  x(x  B  x  A) is true.

B
A

Figure 2 Venn Diagram Showing that A is a subset of B.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 8


Sets may have other sets as member.

A = {, {a}, {b}, {a, b}}


B = {x  x is a subset of the set {a, b}}
These two sets are equal, that is, A = B.

Note that {a}  A, but a  A.

Definition 5: Let S be a set. If there are exactly n distinct elements in S where n is a nonnegative integer, we
say that S is a finite set and that n is the cardinality of S. The cardinality of S is denoted by S.

Example 9: Let A be the set of odd positive integers less than 10, that is, A = {1, 3, 5, 7, 9}. Then A = 5.

Example 10: Let S be the set of letters in the English alphabet. Then S = 26.

Example 11: Since the null set has no elements,  = 0.

Definition 6: A set is said to be infinite if it is not finite.

Example 12: The set of positive integers is infinite.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 9


The Power Set

Definition 7: Given a set S, the power set of S is the set of all subsets of the set S. The power set of S is denoted
by P(S).

Example 13: What is the power set of the set {0, 1, 2}?

Solution:
P({0, 1, 2})
= {, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}}

Example 14: What is the power set of the empty set? What is the power set of the set {}?

Solution:
P() = {}.
P({}) = {, {}}

If a set has n elements, then its power set has 2n elements.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 10


Cartesian Products

Definition 8: The ordered n-tuple (a1, a2, , an) is the ordered collection that has a1 as its first element, a2 as
its second element, , and an as its nth element.

We say that 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.

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.

(a, b) and (b, a) are not equal unless a = b.

Definition 9: Let A and B be sets. The Cartesian product of A and B, denoted by A  B, is the set of all ordered
pairs (a, b) where a  A and b  B.
Hence, A  B = {(a, b)  a  A  b  B}.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 11


Example 16: What is the Cartesian product of A = {1, 2} and B = {a, b, c}?

Solution:
A  B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}

A subset R of the Cartesian product A  B is called a relation from the set A to the set B.
The elements of R are ordered pairs, where the first element belongs to A and the second to B.

For example,
R = {(a, 0), (a, 1), (a, 3), (b, 1), (b, 2), (c, 0), (c, 3)}
is a relation from the set {a, b, c} to the set {0, 1, 2, 3}.

The Cartesian product A  B and B  A are not equal, unless A =  or B =  (so that A  B = ) or unless
A = B.

Example 17: Show that the Cartesian product B  A is not equal to the Cartesian product A  B, where
A = {1, 2} and B = {a, b, c}.

Solution:
B  A = {(a, 1), (a, 2), (b, 1), (b, 2), (c, 1). (c, 2)}
A  B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}
Therefore, B  A  A  B.
Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 12
Example 18: What is the Cartesian product A  B  C, where A = {0, 1}, B = {1, 2}, and C = {0, 1, 2}?

Solution:
AB
= {0, 1}  {1, 2}
= {(0, 1), (0, 2), (1, 1), (1, 2)}

(A  B)  C
= {(0, 1), (0, 2), (1, 1), (1, 2)}  {0, 1, 2}
= {(0, 1, 0), (0, 1, 1), (0, 1, 2),
(0, 2, 0), (0, 2, 1), (0, 2, 2),
(1, 1, 0), (1, 1, 1), (1, 1, 2),
(1, 2, 0), (1, 2, 1), (1, 2, 2)}

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 13


2.2 Set Operations

Definition 1: Let A and B be sets. The union of the sets A and B, denoted by A  B, is the set that contains
those elements that are either in A or in B, or in both.
A  B = {x  x  A  x  B}.

A B

A  B is shaded
Figure 1 Venn Diagram Representing the Union of A and B.
Example 1: {1, 3, 5}  {1, 2, 3} = {1, 2, 3, 5}

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 14


Definition 2: Let A and B be sets. The intersection of the sets A and B, denoted by A  B, is the set that
contains those elements in both A and B.
A  B = {x  x  A  x  B}.

A B

A  B is shaded
Figure 2 Venn Diagram Representing the Intersection of A and B.
Example 3: {1, 3, 5}  {1, 2, 3} = {1, 3}

Definition 3: Two sets are called disjoint if their intersection is the empty set.

Example 5: Let A = {1, 3, 5, 7, 9} and B = {2, 4, 6, 8, 10}. Since A  B = , A and B are disjoint.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 15


Definition 4: Let A and B be sets. The difference of A and B, denoted by AB, is the set containing those
elements that are in A but not in B.
The difference of A and B is also called the complement of B with respect to A.
AB = {xxAxB}
AB = A𝐵

U
B
A

A  B is shaded.
Figure 3 Venn Diagram for the Difference of A and B.
Example 6:
{1, 3, 5}  {1, 2, 3} = {5}
{1, 2, 3}  {1, 3, 5} = {2}

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 16


Definition 5: Let U be the universal set. The complement of the set A, denoted by 𝐴, is the complement of A
with respect to U. In other words, the complement of the set A is UA.
𝐴 = {xxA}

𝐴 is shaded.
Figure 4 Venn Diagram for the Complement of the Set A.

Example 8: Let A = {a, e, i, o, u} (where the universal set is the set of letters of the English alpohabet).
Then 𝐴 = {b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, y, z}

Example 9: Let A be the set of positive integers greater than 10 (with universal set the set of all positive
integers).
Then 𝐴 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 17


Generalized Unions and Intersections

A  B  C contains those elements that are in at least one of the sets A, B, and C.
A  B  C contains those elements that are in all of sets A, B, and C.
U U
A B B
A

C C

(a) A  B  C is shaded. (b) A  B  C is shaded.


Figure 5 The Union and Intersection of A, B, and C.
Example 15:
Let A = {0, 2, 4, 6, 8}, B = {0, 1, 2, 3, 4}, and C = {0, 3, 6, 9}. What are A  B  C and A  B  C?

Solution:
A  B = {0, 2, 4, 6, 8}  {0, 1, 2, 3, 4} = {0, 1, 2, 3, 4, 6, 8}
(A  B)  C = {0, 1, 2, 3, 4, 6, 8}  {0, 3, 6, 9} = {0, 1, 2, 3, 4, 6, 8, 9}

A  B = {0, 2, 4, 6, 8}  {0, 1, 2, 3, 4} = {0, 2, 4}


(A  B)  C = {0, 2, 4}  {0, 3, 6, 9} = {0}
Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 18
Computer Representation of Sets

Assume that the universal set U is finite.


First, specify an arbitrary ordering of the elements of U, for instance a1, a2, , an.
Represent a subset A of U with the bit string of length n, where the ith bit in this string is 1 if ai belongs to A
and is 0 if ai does not belong to A.

Example 18: Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, and the ordering of elements of U has the elements in
increasing order. What bit strings represent the subset A of all odd integers in U, the subset B of all even
integers in U, and the subset C of integers not exceeding 5 in U?

Solution:
U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
A = {1, 3, 5, 7, 9}
B = {2, 4, 6, 8, 10}
C = {1, 2, 3, 4, 5}

Bit strings
U = 11 1111 1111
A = 10 1010 1010
B = 01 0101 0101
C = 11 1110 0000
Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 19
Example 19: The universal set is U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. The given set is A = {1, 3, 5, 7, 9}. What is
the bit string for 𝐴 ?

Solution:
U = 11 1111 1111
A = 10 1010 1010
𝐴 = 01 0101 0101 (Bit-wise complement)

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 20


Example 20:
The universal set is U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
Two sets are A = {1, 2, 3, 4, 5} and B = (1, 3, 5, 7, 9}.
Use bit strings to find A  B, A  B, and A  B.

Solution:
U = 11 1111 1111

Union:
A= 11 1110 0000
B= 10 1010 1010
-----------------------------
A  B = 11 1110 1010 (bit-wise OR)
The corresponding set is A  B = {1, 2, 3, 4, 5, 7, 9}

Intersection:
A= 11 1110 0000
B= 10 1010 1010
-----------------------------
A  B = 10 1010 0000 (bit-wise AND)
The corresponding set is A  B = {1, 3, 5}

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 21


Example 20 (contd):
The universal set is U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
Two sets are A = {1, 2, 3, 4, 5} and B = (1, 3, 5, 7, 9}.
Use bit strings to find AB,AB, and AB.

Solution:
U = 11 1111 1111

Difference:
A= 11 1110 0000
B= 10 1010 1010
𝐵= 01 0101 0101

A= 11 1110 0000
𝐵= 01 0101 0101
------------------------------------------
AB = 01 0100 0000 (Bit-wise AND)
The corresponding set is AB = {2, 4}

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 22


2.3 Functions

Definition 1:
Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A.
We write f(a) = b if b is the unique element of B assigned by the function f to the element a of A.
If f is a function from A to B, we write f : A  B.

Adams A
Chou B
Goodfriend C
Rodriguez D
Stevens F

Figure 1 Assignment of Grades in a Discrete Mathematics Class.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 23


Definition 2:
If f is a function from A to B, we say that A is the domain of f and B is the codomain of f.
If f(a) = b, we say that b is the image of a and a is a pre-image of b.
The range of f is the set of all images of elements of A.
Also, if f is a function from A to B, we say that f maps A to B.

f
a b  f (a )

A f B
Figure 2: The function f maps A to B.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 24


Example 1: What are the domain, codomain, and range of the function that assigns grades to students in
discrete mathematics class described in the following figure?
Adams A
Chou B
Goodfriend C
Rodriguez D
Stevens F
Solution:
Let G be the function that assigns a grade to a student in discrete mathematics class.

G(Adams) = A.

The domain of G is the set {Adams, Chou, Goodfriend, Rodriguez, Stevens}

The codomain of G is the set {A, B, C, D, F}

The range of G is the set {A, B, C, F}.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 25


Example 2: Let R be the relation consisting of ordered pairs
(Abdul, 22), (Brenda, 24), (Carla, 21), (Desire, 22), (Eddie, 24), and (Felicia, 22),
where each pair consists of a graduate student and the age of this student. What is the function that this relation
determines?

Solution:
This relation defines the function f, where
f(Abdul) = 22
f(Brenda) = 24
f(Carla) = 21
f(Desire) = 22
f(Eddie) = 24
f(Felicia) = 22.

Here the domain is the set


{Abdul, Brenda, Carla, Desire, Eddie, Felicia}.

The codomain is the set of positive integers.

The range is the set {21, 22, 24}.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 26


Example 4: Let f : Z  Z assign the square of an integer to an integer. Then, f(x) = x2, where the domain of f is
the set of all integers, the codomain of f is the set of all integers, and the range of f is the set of all integers that
are perfect squares, namely, {0, 1, 4, 9, …}.

Definition 3: Let f1 and f2 be functions from A to R. Then f1 + f2 and f1 f2 are also functions from A to R defined
by
(f1 + f2)(x) = f1(x) + f2(x),
(f1 f2)(x) = f1(x) f2(x).

Example 6: Let f1 and f2 be functions from R to R such that f1(x) = x2 and f2(x) = x – x2. What are the functions
f1 + f2 and f1 f2?

Solution:
(f1 + f2)(x) = f1(x) + f2(x) = x2 + (x – x2) = x
(f1 f2)(x) = f1(x)f2(x) = x2 (x – x2) = x3 – x4

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 27


One-to-One and Onto Functions

Definition 5: A function f is said to be one-to-one, or injective, if and only if f(a) = f(b) implies that a = b for
all a and b in the domain of f.

Example 8: Determine whether the function f from {a, b, c, d} to {1, 2, 3, 4, 5} with f(a) = 4, f(b) = 5, f(c) = 1,
and f(d) = 3 is one-to-one.

Solution:
The function f is one-to-one, since f takes on different values at the four elements of its domain.
a 1

b 2

c 3

d 4

5 Figure 3 A one-to-one Function.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 28


Example 9: Determine whether the function f(x) = x2 from the set of integers to the set of integers is one-to-
one.

Solution:
The function f(x) = x2 is not one-to-one, since f(1) = f(1) = 1, but 1  1.

Example 10: Determine whether the function f(x) = x + 1 from the set of real numbers to itself is one-to-one.

Solution:
The function f(x) = x + 1 is one-to-one, since x + 1  y + 1 when x  y.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 29


Definition 7: A function f from A to B is called onto, or surjective, if and only if for every element b  B there
is an element a  A with f(a) = b.

Example 11: Let f be the function from {a, b, c, d} to {1, 2, 3} defined by f(a) = 3, f(b) = 2, f(c) = 1, and
f(d) = 3. Is f an onto function?

Solution:
Since all three elements of the codomain are images of elements in the domain, f is onto.
a 1

b 2

c 3

Figure 4 An Onto Function.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 30


Example 12: Is the function f(x) = x2 from the set of integers to the set of integers onto?

Solution:
The function f is not onto since there is no integer x with x2 = 1, for example.

Example 13: Is the function f(x) = x + 1 from the set of integers to the set of integers onto?

Solution:
This function is onto, since for every integer y there is an integer x such that f(x) = y.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 31


Definition 8: The function f is a one-to-one correspondence, or a bijective, if it is both one-to-one and onto.

Example 14: Let f be the function from {a, b, c, d} to {1, 2, 3, 4} with f(a) = 4, f(b) = 2, f(c) = 1, and f(d) = 3.
Is f a bijective function?

Solution:
f(a) = 4
f(b) = 2
f(c) = 1
f(d) = 3

Each element of the domain maps to unique element of the codomain. So, the function f is one-to-one.
All elements of the codomain are mapped. So, the function f is onto.
As the function f is both one-to-one and onto function, it is a bijective function.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 32


a 1 a 1 a 1

b 2 b 2 b 2

c 3 c 3 c 3

4 d d 4
one - to - one, onto, one - to - one,
not onto not one - to - one and onto
a 1 a 1

b 2 b 2

c 3 c 3

d 4 4
Neither one - to - one, Not a function
nor onto

Figure 5 Examples of Different Types of Correspondance.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 33


Inverse Functions and Compositions of Functions

Definition 9: Let f be a bijective function from the set A to the set B. The inverse function of f is the function
that assigns to an element b belonging to B the unique element a in A such that f(a) = b. The inverse function of
f is denoted by f1. Hence, f1(b) = a when f(a) = b.
f 1 (b)

a  f 1 (b) f (a) b  f (a)

A f 1 B

f
Figure 6 The Function f1 is the Inverse of Function f.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 34


• If a function f is not bijective, we cannot define an inverse function of f.
• A bijective function is called invertible because we can define an inverse of this function.
• A function is not invertible if it is not bijective function, because the inverse of such function does not
exist.

Example 16: Let f be the function from {a, b, c} to {1, 2, 3} such that f(a) = 2, f(b) = 3, and f(c) = 1. Is f
invertible, and if it is, what is its inverse?

Solution:
f(a) = 2
f(b) = 3
f(c) = 1

The function f is a bijective function and is invertible.

The inverse function f1is


f1(1) = c
f1(2) = a
f1(3) = b.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 35


Example 17: Let f: ZZ be such that f(x) = x + 1. Is f invertible, and if it is, what is its inverse?

Solution:
The function f is a bijective function and is invertible.

Suppose that y is the image of x, so that y = x + 1.


Then x = y – 1. This means that y – 1 is the unique element of Z that is sent to y by f.
Consequently,f1(y) = y – 1.

Example 18: Let f be the function from R to R with f(x) = x2. Is f invertible?

Solution:
Since f(2) = f(2) = 4, f is not one-to-one. So, f is not a bijective function. Hence, f is not invertible.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 36


Example 19:Let f be the function from the set of all nonnegative real numbers to the set of all nonnegative real
numbers with f(x) = x2. Show that f is invertible.

Solution:
If f(x) = f(y), then x2 = y2, so x2 – y2 = (x + y)(x – y) =0.
This means that x + y = 0 or x – y = 0, so x = y or x = y. Because both x and y are nonnegative, we must have x
= y. so, f(x) = x2 is one-to-one.

Furthermore, f(x) = x2 is onto when the codomain is the set of all nonnegative real numbers, because each
nonnegative real number has a square root. That is, if y is a nonnegative real number, there exists a nonnegative
real number x such that x = y, which means that x2 = y.

Because the function f(x) = x2 from the set of nonnegative real numbers to the set of nonnegative real numbers
is one-to-one and onto, it is a bijective function and is invertible.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 37


Definition 10: Let g be a function from the set A to the set B and let f be a function from the set B to the set C.
The composition of the functions f and g, denoted by f ○ g, is defined by (f○g)(a) = f(g(a)).

To find (f ○ g)(a) we first apply the function g to a to obtain g(a) and then we apply the function f to the result
of g(a) to obtain (f ○ g)(a) = f(g(a)).

The composition f ○ g cannot be defined unless the range of g is a subset of the domain of f.
( f  g )(a)

g (a) f ( g (a))
a g g (a) f f ( g (a))

f g

Figure 7 The Composition of the Functions f and g.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 38


Example 20: Let g be the function from the set {a, b, c} to itself such that g(a) = b, g(b) = c, and g(c) = a. Let f
be the function from the set {a, b, c} to the set {1, 2, 3} such that f(a) = 3, f(b) = 2, and f(c) = 1. What is the
composition of f and g, and what is the composition of g and f?

Solution:
g(a) = b
g(b) = c
g(c) = a

f(a) = 3
f(b) = 2
f(c) = 1

The composition f ○ g is defined by


(f ○ g)(a) = f(g(a)) = f(b) = 2,
(f ○ g)(b) = f(g(b)) = f(c) = 1,
(f ○ g)(c) = f(g(c)) = f(a) = 3.

g ○ f is not defined, because the range of f is not a subset of the domain of g.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 39


Example 21: Let f and g be the functions from the set of integers to the set of integers defined by f(x) = 2x + 3
and g(x) = 3x + 2. What is the composition of f and g? What is the composition of g and f?

Solution:
(f ○ g)(x) = f(g(x)) = f(3x + 2) = 2(3x + 2) + 3 = 6x + 7
(g ○ f)(x) = g(f(x)) = g(2x + 3) = 3(2x + 3) + 2 = 6x + 11

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 40


Chapter 4
Induction and Recursion

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 41


4.3 Recursive Definitions and Structural Induction

Recursively Defined Functions

We use two steps to define a function with the set of nonnegative integers as its domain:

BASIS STEP: Specify the value of the function at zero.


RECURSIVE STEP: Derive a rule for finding its value at an integer from its values at smaller integers.

Such a definition is called a recursive or inductive definition.

Example 1: Suppose that f is defined recursively by


f(0) = 3
f(n+1) = 2f(n) + 3
Find f(1), f(2), f(3), and f(4).

Solution:
f(0) = 3
f(1) = 2f(0) + 3 = 2  3 + 3 = 9
f(2) = 2f(1) + 3 = 2  9 + 3 = 21
f(3) = 2f(2) + 3 = 2  21 + 3 = 45
f(4) = 2f(3) + 3 = 2  45 + 3 = 93
Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 42
Example 2: Give an recursive definition of the factorial function F(n) = n!.

Solution:
F(0) = 1
F(n + 1) = (n + 1) F(n)

F(5) = 5F(4)
= 5 4F(3)
= 5  4 3F(2)
= 5  4  3 2F(1)
= 5 4  3  2  1F(0)
=543211
= 120

Example 3: Give a recursive definition of an, where a is a nonzero real number and n is a nonnegative integer.

Solution:
a0 = 1
an+1 = aan for n = 1, 2, 3 

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 43


Example 5: The Fibonacci numbers, f0, f1, f2, , are defined by the equations
f0 = 0
f1 = 1
fn = fn 1 + fn 2 for n = 2, 3, 4, 
Find the Fibonacci numbers f2, f3, f4, f5, and f6.

Solution:
f0 = 0
f1 = 1

f2 = f1 + f0 = 1 + 0 = 1
f3 = f2 + f1 = 1 + 1 = 2
f4 = f3 + f2 = 2 + 1 = 3
f5 = f4 + f3 = 3 + 2 = 5
f6 = f5 + f4 = 5 + 3 = 8

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 44


Chapter 7
Relations

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 45


7.1 Relations and Their properties

Defintion 1: Let A and B be sets. A binary relation from A to B is a subset of AB.

A binary relation from A to B is a set R of ordered pairs where the first element of each ordered pair comes from
A and the second element comes from B.

We use the notation aRb to denote that (a, b) R.

When (a, b) belongs to R, a is said to be related to b by R.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 46


Example 3: Let A = {0, 1, 2} and B = {a, b}.
Then {(0, a), (0, b), (1, a), (2, b)} is a relation from A to B.
This means that 0Ra.

Relations can be represented graphically, as shown in Figure 1, using arrows to represent ordered pairs. Another
way to represent this relation is to use a table, which is also done in Figure 1.

0
R a b
a 0 X X
1 1X
b 2 X
2

Figure 1. Displaying the Ordered Pairs in the Relation R from Example 3.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 47


Functions as Relations

A function f from a set A to a set B assigns exactly one element of B to each element of A. The graph of f is the
set of ordered pairs (a, b) such that b = f(a). Since the graph of f is a subset of AB, it is a relation from A to B.
Moreover, the graph of a function has the property that every element of A is the first element of exactly one
ordered pair of the graph.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 48


Relations on a Set

Definition 2: A relation on the set A is a relation from A to A.

Example 4: Let A be the set {1, 2, 3, 4}. Which ordered pairs are in the relation R = {(a, b)a divides b}?

Solution:
R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}

1 1 1 2 3 4
1   
2 2 2  
3 
3 3 4 

4 4

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 49


Example 5: Consider these relations on the set of integers:

R1 = {(a, b)a  b}
R2 = {(a, b)a > b}
R3 = {(a, b)a = b or a = b}
R4 = {(a, b)a = b}
R5 = {(a, b)a = b + 1}
R6 = {(a, b)a + b  3}

Which of these relations contain each of the pairs (1, 1), (1, 2), (2, 1), (1, 1), and (2, 2)?

Solution:
(1, 1) is in R1, R3, R4, R6
(1, 2) is in R1, R6
(2, 1) is in R2, R5, R6
(1, 1) is in R2, R3, R6
(2, 2) is in R1, R3, R4

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 50


Properties of Relations

Definition 3: A relation R on a set A is called reflexive if (a, a)  R for every element a  A.


The relation R on the set A is reflexive if a  A ((a, a)  R).
A relation on A is reflexive if every element of A is related to itself.

Example 7: Consider the following relations on {1, 2, 3, 4}:

R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}
R2 = {(1, 1), (1, 2), (2, 1)}
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}
R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}
R6 = {(3, 4)}

Which of these relations are reflexive?

Solution:
The following relations are reflexive:
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 51


Example 8: Which of the following relations are reflexive?

R1 = {(a, b)a  b}
R2 = {(a, b)a > b}
R3 = {(a, b)a = b or a = b}
R4 = {(a, b)a = b}
R5 = {(a, b)a = b + 1}
R6 = {(a, b)a + b  3}

Solution:
The following relations are reflexive:

R1 = {(a, b)a  b} (since a  a for every integer a)


R3 = {(a, b)a = b or a = b} (since a = a for every integer a)
R4 = {(a, b)a = b} (since a = a for every integer a)

Example 9: Is the “divides” relation on the set of positive integers reflexive?

Solution:
Since a a whenever a is a positive integer, the “divides” relation is reflexive.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 52


Definition 4: A relation R on a set A is called symmetric if (b, a)  R whenever (a, b)  R, for all a, b  A.
A relation R on a set A such that for all a, b  A, if (a, b)  R and (b, a)  R, then a = b is called antisymmetric.

The relation R on the set A is symmetric if


ab((a, b)  R (b, a)  R).

The relation R on the set A is antisymmetric if


ab(((a, b)  R  (b, a)  R)  (a = b)).

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 53


Example 10: Which of the following relations are symmetric and which are antisymmetric?

R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}
R2 = {(1, 1), (1, 2), (2, 1)}
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}
R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}
R6 = {(3, 4)}

Solution:
The following relations are symmetric, because in each case (b, a) belongs to the relation whenever (a, b) does:

R2 = {(1, 1), (1, 2), (2, 1)}


R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}

The following relations are antisymmetric, because for each of these relations there is no pair of elements a and
b with a  b such that both (a, b) and (b, a) belong to the relation.

R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}
R6 = {(3, 4)}

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 54


Example 10 (contd.): Which of the following relations are symmetric and which are antisymmetric?

R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}
R2 = {(1, 1), (1, 2), (2, 1)}
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}
R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}
R6 = {(3, 4)}

Solution:
The following relations are not antisymmetric, because there is a pair (a, b) with a  b so that (a, b) and (b, a)
are both in the relation:

R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}
R2 = {(1, 1), (1, 2), (2, 1)}
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 55


Example 11: Which of the following relations are symmetric and which are antisymmetric?

R1 = {(a, b)a  b}
R2 = {(a, b)a > b}
R3 = {(a, b)a = b or a = b}
R4 = {(a, b)a = b}
R5 = {(a, b)a = b + 1}
R6 = {(a, b)a + b  3}

Solution:
The following relations are symmetric:

R3 = {(a, b)a = b or a = b} [If a = b then b = a. If a = b then b = a]


R4 = {(a, b)a = b} [If a = b then b = a.]
R6 = {(a, b)a + b  3} [If a + b  3 then b + a  3]

The following relations are antisymmetric:

R1 = {(a, b)a  b} [a  b and b  a imply that a = b]


R2 = {(a, b)a > b} [It is impossible for a > b and b > a]
R4 = {(a, b)a = b} [a = b]
R5 = {(a, b)a = b + 1} [It is impossible that a = b + 1 and b = a + 1]
Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 56
Example 12: Is the “divides” relation on the set of positive integers symmetric? Is it antisymmetric?

Solution:
This relation is not symmetric since 12, but .

It is antisymmetric, for if a and b are positive integers with ab and ba, then a = b.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 57


Definition 5: A relation R on a set A is called transitive if whenever (a, b)  R and (b, c)  R, then (a, c)  R,
for all a, b, c A.
The relation R on a set A is transitive if we have
abc (((a, b) R  (b, c)  R)  (a, c)  R)

Example 13: Which of the following relations are transitive?

R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}
R2 = {(1, 1), (1, 2), (2, 1)}
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}
R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}
R6 = {(3, 4)}

Solution:
The following relation is transitive:

R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}
[(3, 2) and (2, 1)  (3, 1)
(4, 2) and (2, 1)  (4, 1)
(4, 3) and (3, 1)  (4, 1)
(4,3) and (3, 2)  (4, 2)]
Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 58
Example 13 (contd.):
The following relation is transitive:

R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}
[(1, 1) and (1, 2)  (1, 2)
(1, 1) and (1, 3)  (1, 3)
(1, 1) and (1, 4)  (1, 4)
(1, 2) and (2, 2)  (1, 2)
(1, 2) and (2, 3)  (1, 3)
(1, 2) and (2, 4)  (1, 4)
(1, 3) and (3, 3)  (1, 3)
(1, 3) and (3, 4)  (1, 4)
(1, 4) and (4, 4)  (1, 4)
(2, 2) and (2, 3)  (2, 3)
(2, 2) and (2, 4) (2, 4)
(2, 3) and (3, 3) (2, 3)
(2, 3) and (2, 4) (2, 4)
(2, 4) and (4, 4) (2, 4)
(3, 3) and (3, 4) (3, 4)
(3, 4) and (4, 4)  (3, 4)]

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 59


Example 13 (contd.):
The following relation is transitive:

R6 = {(3, 4)}
[There is no pair like (4, a) which would imply the existence of the pair (3, a)]

The following relations are not transitive:

R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}
[There are pairs (3, 4) and (4, 1) but not (3, 1)]

R2 = {(1, 1), (1, 2), (2, 1)


[There are pairs (2, 1) and (1, 2) but not (2, 2)]

R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}
[There are pairs (4, 1) and (1, 2) but not (4, 2)]

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 60


Example 14: Which of the following relations are transitive?

R1 = {(a, b)a  b}
R2 = {(a, b)a > b}
R3 = {(a, b)a = b or a = b}
R4 = {(a, b)a = b}
R5 = {(a, b)a = b + 1}
R6 = {(a, b)a + b  3}

Solution:
The following relations are transitive:

R1 = {(a, b)a  b} [(a  b) and (b  c)  (a  c)]


R2 = {(a, b)a > b} [(a > b) and (b > c)  (a > c)]
R3 = {(a, b)a = b or a = b} [(a = b) and (b = c)  (a = c)]
R4 = {(a, b)a = b} [(a = b) and (b = c)  (a = c)]

The following relations are not transitive:

R5 = {(a, b)a = b + 1} [(2, 1), (1, 0)  R5 but (2, 0)  R5)]


R6 = {(a, b)a + b  3} [(2, 1), (1, 2)  R6 but (2, 2)  R6)]

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 61


Example 15: Is the “divides” relation on the set of positive integers transitive?

Solution:
If a divides b, then b = ak
If b divides c, then c = bl
Then c = a(kl), therefore, a divides c
Hence, the “divides” relation is transitive.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 62


Chapter 5
Counting

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 63


5.1 The Basics of Counting

Basic Counting principles

THE PRODUCT RULE


Suppose that a procedure can be broken down into a sequence of two tasks. If there are n1 ways to do the first
task and n2 ways to do the second task after the first task has been done, then there are n1n2 ways to do the
procedure.

Example 1: A new company with just two employees, Sahin and Parvin, rents a floor of a building with 12
offices. How many ways are there to assign different offices to these two employees?

Solution:
An office can be assigned to Sahin in 12 ways.
After assigning an office to Sahin, an office can be assigned to Parvin in 11 different ways.
Therefore, by the product rule, there are 12  11 = 132 ways to assign offices to these two employees.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 64


Example 2: The chairs of an auditorium are to be labeled with a letter and a positive integer not exceeding 100.
What is the largest number of chairs that can be labeled differently?

Solution:
A letter can be assigned in 26 different ways
An integer can be assigned in 100 different ways
The different ways that a chair can be labeled is 26  100 = 2600
Therefore, the largest number of chairs that can be labeled differently is 2600

Example 4: How many different bit strings are there of length seven?

Solution:
Each of the seven bits can be chosen in two ways
Therefore, there are a total of 2  2  2  2  2  2  2 = 27 = 128 different bit strings of length seven.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 65


Example 9: What is the value of k after the following code has been executed?

k := 0
for i1 := 1 to n1
for i2 := 1 to n2
.
.
.
for im := 1 to nm
k := k + 1

Solution:
The initial value of k is zero
Each time the nested loop is traversed, 1 is added to k
The nested loop is traversed n1n2nm times
Therefore, the final value of k is n1n2nm

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 66


THE SUM RULE
If a first task can be done in n1 ways and second task in n2 ways, and if these tasks cannot be done at the same
time, then there are n1 + n2 ways to do one of these tasks.

Example 11: Suppose that either a member of the mathematics faculty or a student who is mathematics major
is chosen as a representative to a university committee. How many different choices are there for this
representative if there are 37 members of the mathematics faculty and 83 mathematics majors?

Solution:
Choosing a member of the mathematics faculty can be done in 37 ways.
Choosing mathematics major can be done in 83 ways.
There are 37 + 83 = 120 possible ways to pick this representative.

Example 12: A student can choose a computer project from one of three lists. The three lists contain 23, 15,
and 19 possible projects, respectively. How many possible projects are there to choose from?

Solution:
The student can choose a project from the first list in 23 ways, from the second list in 15 ways, and from the
third list in 19 ways.
Hence, there are 23 + 15 + 19 = 57 projects to choose from.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 67


Example 13: What is the value of k after the following code has been executed?

k := 0
for i1 := 1 to n1
k := k + 1
for i2 := 1 to n2
k := k + 1
.
.
.
for im := 1 to nm
k := k + 1

Solution:
The initial value of k is zero.
This block of code is made up of m different loops. Each time a loop is traversed, 1 is added to k.
The final value of k is n1 + n2 +  + nm.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 68


More Complex Counting problems

Example 14: In a version of the computer language BASIC, the name of a variable is a string of one or two
alphanumeric characters, where uppercase and lowercase letters are not distinguished. Moreover, a variable
name must begin with a letter and must be different from the five strings of two characters that are reserved for
programming use. How many different variables names are there in this version of BASIC?

Solution:
Let V equal the number of different variable names in this version of BASIC.

Let V1 be the number of these that are one character long.


V1 = 26

Let V2 be the number of these that are two characters long


V2 = 26  36 – 5 = 931

V = V1 + V2 = 26 + 931 = 957

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 69


Example 15: Each user on a computer system has a password, which is six to eight characters long, where each
character is an uppercase letter or a digit. Each password must contain at least one digit. How many possible
passwords are there?

Solution:
Let P be the total number of possible passwords, and P6, P7, and P8 denote the number of possible passwords of
length 6, 7, and 8, respectively.

The number of strings of six characters is 366


The number of strings with no digits is 266
 P6 = 366 – 266 = 2,176,782,336 – 308,915,776 = 1,867,866,560

Similarly,
P7 = 367 – 267 = 78,367,164,096 – 8,031,810,176 = 70,332,353,920

P8 = 368 – 268 = 2,821,109,907,456 – 208,827,064,576 = 2,612,282,842,880

P = P6 + P7 + P8 = 1,867,866,560 + 70,332,353,920 + 2,612,282,842,880 = 2,684,483,063,360

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 70


The Inclusion-Exclusion Principle

When two tasks can be done at the same time, we cannot use the sum rule to count the number of ways to do
one of the two tasks. Adding the number of ways to do each task leads to an overcount, since the ways to do
both tasks are counted twice. To correctly count the number of ways to do one of the two tasks, we add the
number of ways to do each of the two tasks and then subtract the number of ways to do both tasks. This
technique is called the principle of inclusion-exclusion.

Example 17: How many bit strings of length eight either starts with a 1 bit or end with the two bits 00?

Solution:
Constructing a bit string of length eight beginning with a 1 bit can be done in 27 = 128 ways.

Constructing a bit string of length eight ending with the two bits 00 can be done in 26 = 64 ways.

Constructing a bit string of length eight that begins with a 1 and ends with 00 can be done in 25 = 32 ways.

Consequently, the number of bit strings of length eight that begin with a 1 or end with a 00 equals
128 + 64 – 32 = 160.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 71


Tree Diagrams

Counting problems can be solved using tree diagrams. To use trees in counting, we use a branch to represent
each possible choice. We represent the possible outcomes by the leaves.

Example 19: How many bit string of length four do not have two consecutive 1s?

Solution:
1st bit 1 0
2nd bit 0 1 0
3rd bit 1 0 0 1 0
4th bit
0 1 0 1 0 0 1 0
1001

0101

0001
1010

1000

0100
0010

0000
The tree diagram displays all bit strings of length four without two consecutive 1s. We see that there are eight
bit strings of length four without two consecutive 1s.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 72


5.2 The Pigeonhole Principle

Theorem 1: THE PIGEONHOLE PRINCIPLE


If k is a positive integer and k + 1 or more objects are placed into k boxes, then there is at least one box
containing two or more of the objects.

Proof.
Suppose that none of the k boxes contains more than one object. Then the total number of objects would be at
most k. This is a contradiction, since there are at least k + 1 objects.

Example 1: Among any group of 367 people, there must be at least two with the same birthday, because there
are only 366 possible birthdays.

Example 2: In any group of 27 English words, there must be at least two that begin with the same letter, since
there are 26 letters in the English alphabet.

Example 3: How many students must be in a class to guarantee that at least two students receive the same
score on the final exam, if the exam is graded on a scale from 0 to 100?

Solution:
There are 101 possible scores on the final. The pigeonhole principle shows that among any 102 students there
must be at least 2 students with the same score.
Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 73
The Generalized Pigeonhole principle

Theorem 2: THE GENERALIZED PIGEONHOLE PRINCIPLE


If N objects are placed into k boxes, then there is at least one box containing at least N/k objects.

Proof:
Suppose that none of the boxes contain more than N/k 1 objects. Then, the total number of objects is at most
 N    N  
k     1  k    1  1  N
 k    k  
This is a contradiction, since there are a total of N objects.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 74


A common type of problem asks for the minimum number of objects so that at least r of these objects must be
in one of k boxes when these objects are distributed among the boxes.

When we have N objects, the generalized pigeonhole principle tells us that there must be at least r objects in
one of the boxes as long as

N/k  r
N/k + 1 > r
N/k > (r – 1)
N > k(r – 1)
N = k(r – 1) + 1 is the smallest integer satisfying the condition

Example 5: Among 100 people there are at least 100/12 = 9 who were born in the same month.

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 75


Example 6: What is the minimum number of students required in a discrete mathematics class to be sure that at
least six will receive the same grade, if there are five possible grades, A, B, C, D, and F?

Solution:
Let
N = minimum number of students to satisfy the condition
k = 5 = total number of grades
r = 6 = minimum number of students receiving the same grade

N = k(r – 1) + 1 = 5 (6 – 1) + 1 = 26

Md. Mozammel Huq Azad Khan, Professor, CSE, EWU Page 76

You might also like