Lab 5

Transcription

Lab 5
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
CSC 10400: Discrete Mathematical Structures
Recitation
Chapter 5
Lecturer: Pavel Rytir
The City College of New York
2015
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Cartesian Products and Relations
Cartesian Product
Let A and B be sets. The Cartesian product, or cross product,
of A and B is denoted by A × B and is defined by
{(x, y )|x ∈ A, y ∈ B}.
Relation
For sets A and B, a (binary) relation from A to B is a subset
of A × B.
Theorem 5.1
For any sets A, B, C ⊆ U.
A × (B ∩ C ) = (A × B) ∩ (A × C )
A × (B ∪ C ) = (A × B) ∪ (A × C )
(A ∩ B) × C ) = (A × C ) ∩ (B × C )
(A ∪ B) × C ) = (A × C ) ∪ (B × C )
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 1
If A = {1, 2, 3, 4}, B = {2, 5}, and C = {3, 4, 7}, determine A × B;
B × A; A ∪ (B × C ); (A ∪ B) × C ; (A × C ) ∪ (B × C ).
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 1
If A = {1, 2, 3, 4}, B = {2, 5}, and C = {3, 4, 7}, determine A × B;
B × A; A ∪ (B × C ); (A ∪ B) × C ; (A × C ) ∪ (B × C ).
Answer
A × B = {(1, 2), (2, 2), (3, 2), (4, 2), (1, 5), (2, 5), (3, 5), (4, 5)}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 1
If A = {1, 2, 3, 4}, B = {2, 5}, and C = {3, 4, 7}, determine A × B;
B × A; A ∪ (B × C ); (A ∪ B) × C ; (A × C ) ∪ (B × C ).
Answer
A × B = {(1, 2), (2, 2), (3, 2), (4, 2), (1, 5), (2, 5), (3, 5), (4, 5)}.
B × A = {(2, 1), (2, 2), (2, 3), (2, 4), (5, 1), (5, 2), (5, 3), (5, 4)}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 1
If A = {1, 2, 3, 4}, B = {2, 5}, and C = {3, 4, 7}, determine A × B;
B × A; A ∪ (B × C ); (A ∪ B) × C ; (A × C ) ∪ (B × C ).
Answer
A × B = {(1, 2), (2, 2), (3, 2), (4, 2), (1, 5), (2, 5), (3, 5), (4, 5)}.
B × A = {(2, 1), (2, 2), (2, 3), (2, 4), (5, 1), (5, 2), (5, 3), (5, 4)}.
A ∪ (B × C ) = {1, 2, 3, 4, (2, 3), (2, 4), (2, 7), (5, 3), (5, 4), (5, 7)}
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 1
If A = {1, 2, 3, 4}, B = {2, 5}, and C = {3, 4, 7}, determine A × B;
B × A; A ∪ (B × C ); (A ∪ B) × C ; (A × C ) ∪ (B × C ).
Answer
A × B = {(1, 2), (2, 2), (3, 2), (4, 2), (1, 5), (2, 5), (3, 5), (4, 5)}.
B × A = {(2, 1), (2, 2), (2, 3), (2, 4), (5, 1), (5, 2), (5, 3), (5, 4)}.
A ∪ (B × C ) = {1, 2, 3, 4, (2, 3), (2, 4), (2, 7), (5, 3), (5, 4), (5, 7)}
(A ∪ B) × C ) = (A × C ) ∪ (B × C )
= {(1, 3), (2, 3), (3, 3), (4, 3), (5, 3), (1, 4), (2, 4), (3, 4), (4, 4),
(5, 4), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7)}
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 3
Let A = {1, 2, 3, 4}, and let B = {2, 4, 5}. Determine the following
(a) |A × B|
(b) the number of relations from A to B.
(c) the number of relations on A.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 3
Let A = {1, 2, 3, 4}, and let B = {2, 4, 5}. Determine the following
(a) |A × B|
(b) the number of relations from A to B.
(c) the number of relations on A.
Answer
(a) |A × B| = |A||B| = 12
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 3
Let A = {1, 2, 3, 4}, and let B = {2, 4, 5}. Determine the following
(a) |A × B|
(b) the number of relations from A to B.
(c) the number of relations on A.
Answer
(a) |A × B| = |A||B| = 12
(b) The relation from A to B is a subset of A × B, there are 212
relations from A to B.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 3
Let A = {1, 2, 3, 4}, and let B = {2, 4, 5}. Determine the following
(a) |A × B|
(b) the number of relations from A to B.
(c) the number of relations on A.
Answer
(a) |A × B| = |A||B| = 12
(b) The relation from A to B is a subset of A × B, there are 212
relations from A to B.
(c) Since |A × A| = 16, there are 216 relations on A
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 3 Continue
Let A = {1, 2, 3, 4}, and let B = {2, 4, 5}. Determine the following
(d) the number of relations from A to B that contain (1, 2) and
(1, 5).
(e) the number of relations from A to B that contain exactly five
ordered pairs.
(f) the number of relations on A that contain at least 13 elements.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 3 Continue
Let A = {1, 2, 3, 4}, and let B = {2, 4, 5}. Determine the following
(d) the number of relations from A to B that contain (1, 2) and
(1, 5).
(e) the number of relations from A to B that contain exactly five
ordered pairs.
(f) the number of relations on A that contain at least 13 elements.
Answer
(d) For other ten ordered paris in A × B, there are two choices:
include it in the relation or leave it out. Hence there are 210
relations from A to B that contain (1, 2) and (1, 5)
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 3 Continue
Let A = {1, 2, 3, 4}, and let B = {2, 4, 5}. Determine the following
(d) the number of relations from A to B that contain (1, 2) and
(1, 5).
(e) the number of relations from A to B that contain exactly five
ordered pairs.
(f) the number of relations on A that contain at least 13 elements.
Answer
(d) For other ten ordered paris in A × B, there are two choices:
include it in the relation or leave it out. Hence there are 210
relations from A to B that contain (1, 2) and (1, 5)
(e) 12
5
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 3 Continue
Let A = {1, 2, 3, 4}, and let B = {2, 4, 5}. Determine the following
(d) the number of relations from A to B that contain (1, 2) and
(1, 5).
(e) the number of relations from A to B that contain exactly five
ordered pairs.
(f) the number of relations on A that contain at least 13 elements.
Answer
(d) For other ten ordered paris in A × B, there are two choices:
include it in the relation or leave it out. Hence there are 210
relations from A to B that contain (1, 2) and (1, 5)
(e) 12
5
16
16
16
(f) 16
13 + 14 + 15 + 16 .
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 10
A rumor is spread as follows. The originator calls two people. Each
of these people phones three friends, each of whom in turn class five
associates. If no one receives more than one class, and no one calls
the originator, how many people now know the rumor? How many
phone calls were made?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 10
A rumor is spread as follows. The originator calls two people. Each
of these people phones three friends, each of whom in turn class five
associates. If no one receives more than one class, and no one calls
the originator, how many people now know the rumor? How many
phone calls were made?
Answer
The number of people knowing the rumor is 1+2+2×3+2×3×5 =
39.
Since each call lets one more people know the rumor, there are
39 − 1 = 38 calls made.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 12
Let A, B be the sets with |B| = 3. If there are 4096 relations from
A to B, what is |A|.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.1 Cartesian Products and Relations
Problem 12
Let A, B be the sets with |B| = 3. If there are 4096 relations from
A to B, what is |A|.
Answer
Because 4096 = 212 , |A × B| = 12.
12
Therefore, |A| = |A×B|
|B| = 3 = 4.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Functions: Plain and One-to-One
Function
For nonempty sets A and B, a function, or mapping, f from A
to B, denoted by f : A → B, is a relation R from A to B in
which every element of A appears exactly once as the first
component of an ordered pair in the relation.
∀x ∈ A∃y ∈ B((x, y ) ∈ R ∧ ∀z ∈ B((x, z) ∈ R → (y = z)))
We often write f (a) = b when (a, b) ∈ R. Here b is the image
of a under f , and a is a preimage of b.
Domain and Range
For a function f : A → B, A is the domain of f and B is the
codomain of f . The range of f is the set of all elements in B
appearing as the second component in the ordered pairs of f ,
or {y |y ∈ B, (x, y ) ∈ R}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Functions: Plain and One-to-One
One-on-one function
A function f : A → B is called one-to-one, or injective, if each
element of B appears at most once as the image of an
element of A.
Theorem 5.2
Suppose A1 , A2 are subsets of A. We define
f (A1 ) = {b ∈ B|b = f (a), for some a ∈ A1 }. Then the
following hold.
f (A1 ∪ A2 ) = f (A1 ) ∪ f (A2 )
f (A1 ∩ A2 ) ⊆ f (A1 ) ∩ f (A2 )
f (A1 ∩ A2 ) = f (A1 ) ∩ f (A2 ) when f is one-to-one.
Restriction and Extension
Let A1 ⊆ A. Suppose f : A1 → B and g : A → B are two
functions such that f (a) = g (a) for all a ∈ A1 . The function f
is a restriction of g to A1 and g is a extension of f to A.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 1
Determine whether or not each of the following relations is a function. If a relation is a function, find its range
(a) {(x, y )|x, y ∈ Z, y = x 2 + 7}, a relation from Z to Z.
(b) {(x, y )|x, y ∈ R, y 2 = x}, a relation from R to R.
(c) {(x, y )|x, y ∈ R, y = 3x + 1}, a relation from R to R.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 1
Determine whether or not each of the following relations is a function. If a relation is a function, find its range
(a) {(x, y )|x, y ∈ Z, y = x 2 + 7}, a relation from Z to Z.
(b) {(x, y )|x, y ∈ R, y 2 = x}, a relation from R to R.
(c) {(x, y )|x, y ∈ R, y = 3x + 1}, a relation from R to R.
Answer
(a) Function. Range is {7, 8, 11, 16, 23, . . .}
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 1
Determine whether or not each of the following relations is a function. If a relation is a function, find its range
(a) {(x, y )|x, y ∈ Z, y = x 2 + 7}, a relation from Z to Z.
(b) {(x, y )|x, y ∈ R, y 2 = x}, a relation from R to R.
(c) {(x, y )|x, y ∈ R, y = 3x + 1}, a relation from R to R.
Answer
(a) Function. Range is {7, 8, 11, 16, 23, . . .}
(b) Not a function. For example, both (4, 2) and (4, −2) are in
this relation.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 1
Determine whether or not each of the following relations is a function. If a relation is a function, find its range
(a) {(x, y )|x, y ∈ Z, y = x 2 + 7}, a relation from Z to Z.
(b) {(x, y )|x, y ∈ R, y 2 = x}, a relation from R to R.
(c) {(x, y )|x, y ∈ R, y = 3x + 1}, a relation from R to R.
Answer
(a) Function. Range is {7, 8, 11, 16, 23, . . .}
(b) Not a function. For example, both (4, 2) and (4, −2) are in
this relation.
(c) Function. Range is R.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 1 Continue
Determine whether or not each of the following relations is a function. If a relation is a function, find its range
(d) {(x, y )|x, y ∈ Q, x 2 + y 2 = 1}, a relation from Q to Q.
(e) R is a relation from A to B where |A| = 5, |B| = 6, and
|R| = 6.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 1 Continue
Determine whether or not each of the following relations is a function. If a relation is a function, find its range
(d) {(x, y )|x, y ∈ Q, x 2 + y 2 = 1}, a relation from Q to Q.
(e) R is a relation from A to B where |A| = 5, |B| = 6, and
|R| = 6.
Answer
(d) Not a function. For example, both (0, 1) and (0, −1) are in
this relation.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 1 Continue
Determine whether or not each of the following relations is a function. If a relation is a function, find its range
(d) {(x, y )|x, y ∈ Q, x 2 + y 2 = 1}, a relation from Q to Q.
(e) R is a relation from A to B where |A| = 5, |B| = 6, and
|R| = 6.
Answer
(d) Not a function. For example, both (0, 1) and (0, −1) are in
this relation.
(e) Not a function, because |R| > |A|.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 2
Does the formula f (x) = 1/(x 2 − 2) define a function f : R → R?
A function f : Z → R?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 2
Does the formula f (x) = 1/(x 2 − 2) define a function f : R → R?
A function f : Z → R?
Answer
√
The √
formula cannot be used √
for the√domain of R since f ( 2) and
f (− 2) are undefined. Since 2, − 2 ∈
/ Z, the formula does define
a real valued function on the domain Z.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(a) List five functions from A to B.
(b) How many functions f : A → B are there?
(c) How many functions f : A → B are one-to-one?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(a) List five functions from A to B.
(b) How many functions f : A → B are there?
(c) How many functions f : A → B are one-to-one?
Answer
(a) We list five functions as follows.
{(1, x), (2, x), (3, x), (4, x)}
{(1, x), (2, x), (3, x), (4, y )}
{(1, x), (2, x), (3, x), (4, z)}
{(1, x), (2, x), (3, y ), (4, x)}
{(1, x), (2, x), (3, y ), (4, y )}
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(a) List five functions from A to B.
(b) How many functions f : A → B are there?
(c) How many functions f : A → B are one-to-one?
Answer
(a) We list five functions as follows.
{(1, x), (2, x), (3, x), (4, x)}
{(1, x), (2, x), (3, x), (4, y )}
{(1, x), (2, x), (3, x), (4, z)}
{(1, x), (2, x), (3, y ), (4, x)}
{(1, x), (2, x), (3, y ), (4, y )}
(b) For each element in A, we can map it on an element in B.
There are 34 functions from A to B.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(a) List five functions from A to B.
(b) How many functions f : A → B are there?
(c) How many functions f : A → B are one-to-one?
Answer
(a) We list five functions as follows.
{(1, x), (2, x), (3, x), (4, x)}
{(1, x), (2, x), (3, x), (4, y )}
{(1, x), (2, x), (3, x), (4, z)}
{(1, x), (2, x), (3, y ), (4, x)}
{(1, x), (2, x), (3, y ), (4, y )}
(b) For each element in A, we can map it on an element in B.
There are 34 functions from A to B.
(c) Because |A| > |B|, there is no one-to-one function.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3 Continue
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(d) How many functions g : B → A are there?
(e) How many functions g : B → A are one-to-one?
(f) How many functions f : A → B satisfy f (1) = x?
(g) How many functions f : A → B satisfy f (1) = f (2) = x?
(h) How many functions f : A → B satisfy f (1) = x and f (2) = y ?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3 Continue
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(d) How many functions g : B → A are there?
(e) How many functions g : B → A are one-to-one?
(f) How many functions f : A → B satisfy f (1) = x?
(g) How many functions f : A → B satisfy f (1) = f (2) = x?
(h) How many functions f : A → B satisfy f (1) = x and f (2) = y ?
Answer
(d) 43
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3 Continue
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(d) How many functions g : B → A are there?
(e) How many functions g : B → A are one-to-one?
(f) How many functions f : A → B satisfy f (1) = x?
(g) How many functions f : A → B satisfy f (1) = f (2) = x?
(h) How many functions f : A → B satisfy f (1) = x and f (2) = y ?
Answer
(d) 43
(e) P(4, 3) =
4!
1!
= 24.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3 Continue
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(d) How many functions g : B → A are there?
(e) How many functions g : B → A are one-to-one?
(f) How many functions f : A → B satisfy f (1) = x?
(g) How many functions f : A → B satisfy f (1) = f (2) = x?
(h) How many functions f : A → B satisfy f (1) = x and f (2) = y ?
Answer
(d) 43
(e) P(4, 3) =
(f)
33
4!
1!
= 24.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3 Continue
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(d) How many functions g : B → A are there?
(e) How many functions g : B → A are one-to-one?
(f) How many functions f : A → B satisfy f (1) = x?
(g) How many functions f : A → B satisfy f (1) = f (2) = x?
(h) How many functions f : A → B satisfy f (1) = x and f (2) = y ?
Answer
(d) 43
(e) P(4, 3) =
(f)
33
(g) 32
4!
1!
= 24.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 3 Continue
Let A = {1, 2, 3, 4} and B = {x, y , z}.
(d) How many functions g : B → A are there?
(e) How many functions g : B → A are one-to-one?
(f) How many functions f : A → B satisfy f (1) = x?
(g) How many functions f : A → B satisfy f (1) = f (2) = x?
(h) How many functions f : A → B satisfy f (1) = x and f (2) = y ?
Answer
(d) 43
(e) P(4, 3) =
(f)
33
(g) 32
(h) 32
4!
1!
= 24.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 7
Determine each of the following.
(a) b2.3 − 1.6c
(b) b2.3c − b1.6c
(c) d3.4eb6.2c
(d) b3.4cd6.2e
(e) b2πc
(f) 2dπe
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 7
Determine each of the following.
(a) b2.3 − 1.6c
(b) b2.3c − b1.6c
(c) d3.4eb6.2c
(d) b3.4cd6.2e
(e) b2πc
(f) 2dπe
Answer
(a) 0
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 7
Determine each of the following.
(a) b2.3 − 1.6c
(b) b2.3c − b1.6c
(c) d3.4eb6.2c
(d) b3.4cd6.2e
(e) b2πc
(f) 2dπe
Answer
(a) 0
(b) 1
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 7
Determine each of the following.
(a) b2.3 − 1.6c
(b) b2.3c − b1.6c
(c) d3.4eb6.2c
(d) b3.4cd6.2e
(e) b2πc
(f) 2dπe
Answer
(a) 0
(b) 1
(c) 24
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 7
Determine each of the following.
(a) b2.3 − 1.6c
(b) b2.3c − b1.6c
(c) d3.4eb6.2c
(d) b3.4cd6.2e
(e) b2πc
(f) 2dπe
Answer
(a) 0
(b) 1
(c) 24
(d) 21
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 7
Determine each of the following.
(a) b2.3 − 1.6c
(b) b2.3c − b1.6c
(c) d3.4eb6.2c
(d) b3.4cd6.2e
(e) b2πc
(f) 2dπe
Answer
(a) 0
(b) 1
(c) 24
(d) 21
(e) 6
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 7
Determine each of the following.
(a) b2.3 − 1.6c
(b) b2.3c − b1.6c
(c) d3.4eb6.2c
(d) b3.4cd6.2e
(e) b2πc
(f) 2dπe
Answer
(a) 0
(b) 1
(c) 24
(d) 21
(e) 6
(f) 8
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 15
For each of the following functions, determine whether it is one-toone and determine its range.
(a) f : Z → Z, f (x) = 2x + 1
(b) f : Q → Q, f (x) = 2x + 1
(c) f : Z → Z, f (x) = x 3 − x
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 15
For each of the following functions, determine whether it is one-toone and determine its range.
(a) f : Z → Z, f (x) = 2x + 1
(b) f : Q → Q, f (x) = 2x + 1
(c) f : Z → Z, f (x) = x 3 − x
Answer
(a) One-to-one. The range is the set of all odd integers.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 15
For each of the following functions, determine whether it is one-toone and determine its range.
(a) f : Z → Z, f (x) = 2x + 1
(b) f : Q → Q, f (x) = 2x + 1
(c) f : Z → Z, f (x) = x 3 − x
Answer
(a) One-to-one. The range is the set of all odd integers.
(b) One-to-one. The range is Q.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 15
For each of the following functions, determine whether it is one-toone and determine its range.
(a) f : Z → Z, f (x) = 2x + 1
(b) f : Q → Q, f (x) = 2x + 1
(c) f : Z → Z, f (x) = x 3 − x
Answer
(a) One-to-one. The range is the set of all odd integers.
(b) One-to-one. The range is Q.
(c) Since f (1) = f (0), it is not one-to-one. The range is
{0, ±6, ±24, ±60, . . .} = {n3 − n|n ∈ Z}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 15 Continue
For each of the following functions, determine whether it is one-toone and determine its range.
(d) f : R → R, f (x) = e x
(e) f : [−π/2, π/2] → R, f (x) = sin x
(f) f : [0, π] → R, f (x) = sin x
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 15 Continue
For each of the following functions, determine whether it is one-toone and determine its range.
(d) f : R → R, f (x) = e x
(e) f : [−π/2, π/2] → R, f (x) = sin x
(f) f : [0, π] → R, f (x) = sin x
Answer
(d) One-to-one. The range is (0, +∞) = R+ .
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 15 Continue
For each of the following functions, determine whether it is one-toone and determine its range.
(d) f : R → R, f (x) = e x
(e) f : [−π/2, π/2] → R, f (x) = sin x
(f) f : [0, π] → R, f (x) = sin x
Answer
(d) One-to-one. The range is (0, +∞) = R+ .
(e) One-to-one. The range is [−1, 1].
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 15 Continue
For each of the following functions, determine whether it is one-toone and determine its range.
(d) f : R → R, f (x) = e x
(e) f : [−π/2, π/2] → R, f (x) = sin x
(f) f : [0, π] → R, f (x) = sin x
Answer
(d) One-to-one. The range is (0, +∞) = R+ .
(e) One-to-one. The range is [−1, 1].
(f) Since f (π/4) = f (3π/4), it is not one-to-one. The range is
[0, 1].
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 17
Let A = {1, 2, 3, 4, 5}, B = {w , x, y , z}, A1 = {2, 3, 5} ⊆ A, and
g : A1 → B. In how many ways can g be extended to a function
f : A → B?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 17
Let A = {1, 2, 3, 4, 5}, B = {w , x, y , z}, A1 = {2, 3, 5} ⊆ A, and
g : A1 → B. In how many ways can g be extended to a function
f : A → B?
Answer
The extension must include f (1) and f (4). Since |B| = 4, there are
42 = 16 ways to extend the given function g .
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 20
If A = {1, 2, 3, 4, 5} and there are 6720 injective functions f : A →
B, what is |B|?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 20
If A = {1, 2, 3, 4, 5} and there are 6720 injective functions f : A →
B, what is |B|?
Answer
The number of injective (or one-to-one) functions from A to B is
|B|!
P(|B|, 5) = (|B|−5)!
= 6720. Therefore, |B| = 8.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(a)
One version of Ackermann’s function A(m, n) is defined recursively
for m, n ∈ N by
A(m, n) = n + 1
if m = 0, n ≥ 0
A(m, n) = A(m − 1, 1)
if m > 0 and n = 0
A(m, n) = A(m − 1, A(m, n − 1)) if m > 0 and n > 0
Calculate A(1, 3) and A(2, 3).
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(a)
One version of Ackermann’s function A(m, n) is defined recursively
for m, n ∈ N by
A(m, n) = n + 1
if m = 0, n ≥ 0
A(m, n) = A(m − 1, 1)
if m > 0 and n = 0
A(m, n) = A(m − 1, A(m, n − 1)) if m > 0 and n > 0
Calculate A(1, 3) and A(2, 3).
Answer
A(1, 3) = A(0, A(1, 2)) = A(1, 2) + 1
= A(0, A(1, 1)) + 1 = A(1, 1) + 2
= A(0, A(1, 0)) + 2 = A(1, 0) + 3
= A(0, 1) + 3 = 2 + 3 = 5
Similarly, we have A(2, 3) = 9.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(b)
One version of Ackermann’s function A(m, n) is defined recursively
for m, n ∈ N by
A(m, n) = n + 1
if m = 0, n ≥ 0
A(m, n) = A(m − 1, 1)
if m > 0 and n = 0
A(m, n) = A(m − 1, A(m, n − 1)) if m > 0 and n > 0
Prove that A(1, n) = n + 2 for all n ∈ N.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(b)
One version of Ackermann’s function A(m, n) is defined recursively
for m, n ∈ N by
A(m, n) = n + 1
if m = 0, n ≥ 0
A(m, n) = A(m − 1, 1)
if m > 0 and n = 0
A(m, n) = A(m − 1, A(m, n − 1)) if m > 0 and n > 0
Prove that A(1, n) = n + 2 for all n ∈ N.
Answer
A(1, 0) = A(0, 1) = 2 = 0 + 2, the result holds for n = 0.
Assume that A(1, k) = k + 2. Then A(1, k + 1) = A(0, A(1, k)) =
A(0, k + 2) = k + 2 + 1 = (k + 1) + 2. Therefore, A(1, n) = n + 2
for all n ∈ N.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(c)
One version of Ackermann’s function A(m, n) is defined recursively
for m, n ∈ N by
A(m, n) = n + 1
if m = 0, n ≥ 0
A(m, n) = A(m − 1, 1)
if m > 0 and n = 0
A(m, n) = A(m − 1, A(m, n − 1)) if m > 0 and n > 0
For all n ∈ N show that A(2, n) = 3 + 2n.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(c)
One version of Ackermann’s function A(m, n) is defined recursively
for m, n ∈ N by
A(m, n) = n + 1
if m = 0, n ≥ 0
A(m, n) = A(m − 1, 1)
if m > 0 and n = 0
A(m, n) = A(m − 1, A(m, n − 1)) if m > 0 and n > 0
For all n ∈ N show that A(2, n) = 3 + 2n.
Answer
A(2, 0) = A(1, 1) = 1 + 2 = 3 = 3 + 2 × 0, the result holds for
n = 0.
Assume that A(2, k) = 3 + 2k. Then, A(2, k + 1) = A(1, A(2, k)) =
A(2, k) + 2 = 3 + 2k + 2 = 3 + 2(k + 1). Therefore, A(2, n) = 3 + 2n
for all n ∈ N.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(d)
One version of Ackermann’s function A(m, n) is defined recursively
for m, n ∈ N by
A(m, n) = n + 1
if m = 0, n ≥ 0
A(m, n) = A(m − 1, 1)
if m > 0 and n = 0
A(m, n) = A(m − 1, A(m, n − 1)) if m > 0 and n > 0
Verify that A(3, n) = 2n+3 − 3 for all n ∈ N.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(d)
One version of Ackermann’s function A(m, n) is defined recursively
for m, n ∈ N by
A(m, n) = n + 1
if m = 0, n ≥ 0
A(m, n) = A(m − 1, 1)
if m > 0 and n = 0
A(m, n) = A(m − 1, A(m, n − 1)) if m > 0 and n > 0
Verify that A(3, n) = 2n+3 − 3 for all n ∈ N.
Answer
A(3, 0) = A(2, 1) = 3 + 2 × 1 = 5 = 20+3 − 3, the result holds for
n = 0.
Assume that A(3, k) = 2k+3 −3. Then A(3, k +1) = A(2, A(3, k)) =
3+2A(3, k) = 3+2(2k−3 −3) = 2k−2 −3 = 2(k+1)−3 −3. Therefore,
A(3, n) = 2n+3 − 3 for all n ∈ N.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(d)
Given sets A, B, we define a partial function f with domain A and
codomain B as a function from A0 to B where ∅¬A0 ⊂ A.
(a) For A = {1, 2, 3, 4, 5}, B = {w , x, y , z}, how many partial
functions have domain A and codomain B?
(b) Let A, B be sets where |A| = m > 0, and |B| = n > 0. How
many partial functions have domain A and codomain B?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(d)
Given sets A, B, we define a partial function f with domain A and
codomain B as a function from A0 to B where ∅¬A0 ⊂ A.
(a) For A = {1, 2, 3, 4, 5}, B = {w , x, y , z}, how many partial
functions have domain A and codomain B?
(b) Let A, B be sets where |A| = m > 0, and |B| = n > 0. How
many partial functions have domain A and codomain B?
Answer
(a) 54 44 +
5
3
43 +
5
2
42 +
5
1
41 = 55 − 45 − 1
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.2 Functions: Plain and One-to-One
Problem 27(d)
Given sets A, B, we define a partial function f with domain A and
codomain B as a function from A0 to B where ∅¬A0 ⊂ A.
(a) For A = {1, 2, 3, 4, 5}, B = {w , x, y , z}, how many partial
functions have domain A and codomain B?
(b) Let A, B be sets where |A| = m > 0, and |B| = n > 0. How
many partial functions have domain A and codomain B?
Answer
(a) 54 44 + 53 43 + 52 42 + 51 41 = 55 − 45 − 1
m−1
m−2
m
m
(b) m−1
n
+ m−2
n
+ . . . + m1 n1 = (n + 1)m − nm − 1.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Onto Functions: Stirling Numbers of the Second Kind
Onto function
A function f : A → B is called onto, or surjective, if
f (A) = B, that is, ∀y ∈ B∃x ∈ A(f (x) = y ).
Stirling Number
Let |A| = m and |B| = n where m ≥ b. The number of onto
function from A to B is n! × S(m, n), in which S(m, n) is
called a Stirling number of the second kind, and is defined by
n
n
1 X
k
((−1)
S(m, n) =
(n − k)m
n!
n−k
k=1
Theorem 5.3
Let m, n ∈ Z+ with 1 < n ≤ m.
S(m + 1, n) = S(m, n − 1) + nS(m, n)
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 1
Give an example of finite
stes A and B with |A|,
|B| ≥ 4 and a function
f : A → B such that
(a) f is neither one-to-one
nor onto.
(b) f is one-to-one and
not onto.
(c) f is onto but not
one-to-one.
(d) f is onto and
one-to-one.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 1
Give an example of finite
stes A and B with |A|,
|B| ≥ 4 and a function
f : A → B such that
(a) f is neither one-to-one
nor onto.
(b) f is one-to-one and
not onto.
(c) f is onto but not
one-to-one.
(d) f is onto and
one-to-one.
Answer
(a) A = {1, 2, 3, 4}, B = {a, b, c, d, e},
f = {(1, a), (2, a), (3, b), (4, c)}
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 1
Give an example of finite
stes A and B with |A|,
|B| ≥ 4 and a function
f : A → B such that
(a) f is neither one-to-one
nor onto.
(b) f is one-to-one and
not onto.
(c) f is onto but not
one-to-one.
(d) f is onto and
one-to-one.
Answer
(a) A = {1, 2, 3, 4}, B = {a, b, c, d, e},
f = {(1, a), (2, a), (3, b), (4, c)}
(b) A = {1, 2, 3, 4}, B = {a, b, c, d, e},
f = {(1, a), (2, b), (3, c), (4, d)}
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 1
Give an example of finite
stes A and B with |A|,
|B| ≥ 4 and a function
f : A → B such that
(a) f is neither one-to-one
nor onto.
(b) f is one-to-one and
not onto.
(c) f is onto but not
one-to-one.
(d) f is onto and
one-to-one.
Answer
(a) A = {1, 2, 3, 4}, B = {a, b, c, d, e},
f = {(1, a), (2, a), (3, b), (4, c)}
(b) A = {1, 2, 3, 4}, B = {a, b, c, d, e},
f = {(1, a), (2, b), (3, c), (4, d)}
(c) A = {1, 2, 3, 4, 5}, B = {a, b, c, d},
f =
{(1, a), (2, a), (3, b), (4, c), (5, d)}
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 1
Give an example of finite
stes A and B with |A|,
|B| ≥ 4 and a function
f : A → B such that
(a) f is neither one-to-one
nor onto.
Answer
(a) A = {1, 2, 3, 4}, B = {a, b, c, d, e},
f = {(1, a), (2, a), (3, b), (4, c)}
(b) A = {1, 2, 3, 4}, B = {a, b, c, d, e},
f = {(1, a), (2, b), (3, c), (4, d)}
(b) f is one-to-one and
not onto.
(c) A = {1, 2, 3, 4, 5}, B = {a, b, c, d},
f =
{(1, a), (2, a), (3, b), (4, c), (5, d)}
(c) f is onto but not
one-to-one.
(d) A = {1, 2, 3, 4}, B = {a, b, c, d},
f = {(1, a), (2, b), (3, c), (4, d)}
(d) f is onto and
one-to-one.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 2
For each of the following functions f : Z → Z, determine whether
the function is one-to-one and whether it is onto. If the function is
not onto, determine the range f ().
(a) f (x) = x + 7.
(b) f (x) = 2x − 3.
(c) f (x) = −x + 5.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 2
For each of the following functions f : Z → Z, determine whether
the function is one-to-one and whether it is onto. If the function is
not onto, determine the range f ().
(a) f (x) = x + 7.
(b) f (x) = 2x − 3.
(c) f (x) = −x + 5.
Answer
(a) One-on-one and onto.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 2
For each of the following functions f : Z → Z, determine whether
the function is one-to-one and whether it is onto. If the function is
not onto, determine the range f ().
(a) f (x) = x + 7.
(b) f (x) = 2x − 3.
(c) f (x) = −x + 5.
Answer
(a) One-on-one and onto.
(b) One-on-one but not onto. The range consists of all odd
integers.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 2
For each of the following functions f : Z → Z, determine whether
the function is one-to-one and whether it is onto. If the function is
not onto, determine the range f ().
(a) f (x) = x + 7.
(b) f (x) = 2x − 3.
(c) f (x) = −x + 5.
Answer
(a) One-on-one and onto.
(b) One-on-one but not onto. The range consists of all odd
integers.
(c) One-on-one and onto.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 2 Continue
For each of the following functions f : Z → Z, determine whether
the function is one-to-one and whether it is onto. If the function is
not onto, determine the range f ().
(d) f (x) = x 2 .
(e) f (x) = x 2 + x.
(f) f (x) = x 3 .
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 2 Continue
For each of the following functions f : Z → Z, determine whether
the function is one-to-one and whether it is onto. If the function is
not onto, determine the range f ().
(d) f (x) = x 2 .
(e) f (x) = x 2 + x.
(f) f (x) = x 3 .
Answer
(d) Not one-on-one since f (1) = f (−1). Not onto, the range is
{0, 1, 4, 9, 16, . . .}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 2 Continue
For each of the following functions f : Z → Z, determine whether
the function is one-to-one and whether it is onto. If the function is
not onto, determine the range f ().
(d) f (x) = x 2 .
(e) f (x) = x 2 + x.
(f) f (x) = x 3 .
Answer
(d) Not one-on-one since f (1) = f (−1). Not onto, the range is
{0, 1, 4, 9, 16, . . .}.
(e) Not one-on-one since f (0) = f (−1). Not onto, the range is
{0, 2, 6, 12, 30, . . .}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 2 Continue
For each of the following functions f : Z → Z, determine whether
the function is one-to-one and whether it is onto. If the function is
not onto, determine the range f ().
(d) f (x) = x 2 .
(e) f (x) = x 2 + x.
(f) f (x) = x 3 .
Answer
(d) Not one-on-one since f (1) = f (−1). Not onto, the range is
{0, 1, 4, 9, 16, . . .}.
(e) Not one-on-one since f (0) = f (−1). Not onto, the range is
{0, 2, 6, 12, 30, . . .}.
(f) One-to-one but not onto. The range is
{. . . , −64, −27, −8, −1, 0, 1, 8, 27, 64, . . .}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 4
Let A = {1, 2, 3, 4} and B = {1, 2, 3, 4, 5, 6}.
(a) How many functions are there from A to B? How many of
these are one-to-one? How many of these are onto?
(b) How many functions are there from B to A? How many of
these are one-to-one? How many of these are onto?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 4
Let A = {1, 2, 3, 4} and B = {1, 2, 3, 4, 5, 6}.
(a) How many functions are there from A to B? How many of
these are one-to-one? How many of these are onto?
(b) How many functions are there from B to A? How many of
these are one-to-one? How many of these are onto?
Answer
(a) Each of element A can be mapped into one element in B, thus
there are 64 functions from A to B. We need to select 4
elements in B corresponding to the elements in A with
considering order, thus there are P(6, 4) = 6!
2! one-to-one
functions. Since |B| > |A|, there is no onto functions.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 4
Let A = {1, 2, 3, 4} and B = {1, 2, 3, 4, 5, 6}.
(a) How many functions are there from A to B? How many of
these are one-to-one? How many of these are onto?
(b) How many functions are there from B to A? How many of
these are one-to-one? How many of these are onto?
Answer
(a) Each of element A can be mapped into one element in B, thus
there are 64 functions from A to B. We need to select 4
elements in B corresponding to the elements in A with
considering order, thus there are P(6, 4) = 6!
2! one-to-one
functions. Since |B| > |A|, there is no onto functions.
(b) Similarly, there are 46 functions from B to A. Since |B| > |A|,
there is no one-to-one function from B to A. There are
4! × S(6, 4) onto
functions from
B to A, where
1 Pn
k n (n − k)m is the Stirling number.
S(m, n) = n!
(−1)
k=0
n−k
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 9
Use the fact that every polynomial equation having real number
coefficients and odd degree has a real root in order to show that the
function f : R → R, defined by f (x) = x 5 − 2x 2 + x, is an onto
function. Is f one to one?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 9
Use the fact that every polynomial equation having real number
coefficients and odd degree has a real root in order to show that the
function f : R → R, defined by f (x) = x 5 − 2x 2 + x, is an onto
function. Is f one to one?
Answer
Consider the equation x 5 − 2x 2 + x − r = 0, where r is an arbitrary
real number. Because this equation has real number coefficients and
odd degree, it must have a real root. Thus, for any r ∈ R, there
exists a real number (the root) to satisify that x 5 − 2x 2 + x = r ,
i.e., x 5 − 2x 2 + x is onto. However, since f (0) = f (1) = 0, f is not
one-to-one.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 10
Suppose we have 7 different colored balls and 4 containers A, B, C
and D.
(a) In how many ways can we distributed the balls so that no
container is left empty?
(b) In this selection of 7 colored balls, one of them is blue. In how
many ways can we distribute the balls so that no container is
empty and the blue ball is in container B?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 10
Suppose we have 7 different colored balls and 4 containers A, B, C
and D.
(a) In how many ways can we distributed the balls so that no
container is left empty?
(b) In this selection of 7 colored balls, one of them is blue. In how
many ways can we distribute the balls so that no container is
empty and the blue ball is in container B?
Answer
(a) 4! × S(7, 4)
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 10
Suppose we have 7 different colored balls and 4 containers A, B, C
and D.
(a) In how many ways can we distributed the balls so that no
container is left empty?
(b) In this selection of 7 colored balls, one of them is blue. In how
many ways can we distribute the balls so that no container is
empty and the blue ball is in container B?
Answer
(a) 4! × S(7, 4)
(b) If B only contains one blue ball, there are 3! × S(6, 3) ways. If
B contains more than one balls, there are 4! × S(6, 4) ways.
Therefore, the answer is 3! × S(6, 3) + 4! × S(6, 4).
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 10 Continue
Suppose we have 7 different colored balls and 4 containers A, B, C
and D.
(c) If we remove the letters on the containers so that we can no
longer distinguish them, in how many ways can we distribute
the 7 colored balls among the 4 identical containers, with
some container(s) possibly empty?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 10 Continue
Suppose we have 7 different colored balls and 4 containers A, B, C
and D.
(c) If we remove the letters on the containers so that we can no
longer distinguish them, in how many ways can we distribute
the 7 colored balls among the 4 identical containers, with
some container(s) possibly empty?
Answer
(c) Suppose there are 0, 1, 2 and 3 containers not empty, the
corresponding ways are S(7, 4), S(7, 3), S(7, 2) and S(7, 1)
respectively. Therefore, the answer is
S(7, 4) + S(7, 3) + S(7, 2) + S(7, 1).
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 15
A locker has n buttons labeled 1, 2, . . . , n. To open this lock we press
each of n buttons exactly once. If no two or more buttons may be
pressed simultaneously, then there are n! ways to do this. However,
if one may press two or more buttons simultaneously, then there are
more than n! ways to press all of the buttons. For instance, if n = 3,
there are 3! = 6 ways to press the button one at a time, but there
are 13 ways if we can press two or more buttons simultaneously.
How many ways are there to press buttons when n = 4, n = 5, and
more genereal case?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 15
A locker has n buttons labeled 1, 2, . . . , n. To open this lock we press
each of n buttons exactly once. If no two or more buttons may be
pressed simultaneously, then there are n! ways to do this. However,
if one may press two or more buttons simultaneously, then there are
more than n! ways to press all of the buttons. For instance, if n = 3,
there are 3! = 6 ways to press the button one at a time, but there
are 13 ways if we can press two or more buttons simultaneously.
How many ways are there to press buttons when n = 4, n = 5, and
more genereal case?
Answer
Imagine that each pressing action
P corresponds to a container. Therefore, P
when n = 4, we have 4i=1 i!S(4, i) ways;
Pn when n = 5, we
5
have i=1 i!S(5, i) ways; in general, we have i=1 i!S(n, i) ways.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 15 Continue
A locker has n buttons labeled 1, 2, . . . , n. To open this lock we press
each of n buttons exactly once. If no two or more buttons may be
pressed simultaneously, then there are n! ways to do this. However,
if one may press two or more buttons simultaneously, then there are
more than n! ways to press all of the buttons. For instance, if n = 3,
there are 3! = 6 ways to press the button one at a time, but there
are 13 ways if we can press two or more buttons simultaneously.
If the lock has 15 buttons, and we need press 12 of them to open
the lock, in how many ways can this be done?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.3 Onto Functions: Stirling Numbers of the Second Kind
Problem 15 Continue
A locker has n buttons labeled 1, 2, . . . , n. To open this lock we press
each of n buttons exactly once. If no two or more buttons may be
pressed simultaneously, then there are n! ways to do this. However,
if one may press two or more buttons simultaneously, then there are
more than n! ways to press all of the buttons. For instance, if n = 3,
there are 3! = 6 ways to press the button one at a time, but there
are 13 ways if we can press two or more buttons simultaneously.
If the lock has 15 buttons, and we need press 12 of them to open
the lock, in how many ways can this be done?
Answer
We choose 12 buttons from 15 buttons in
P12
each
of them, we have
i=1 i!S(12, i) ways.
P
12
15
i!S(12,
i).
i=1
12
15
12
ways. For
The answer is
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 1
For A = {a, b, c}, let f : A × A → A be the closed binary operation
given in the following table.
f
a
b
c
a
b
a
c
b
a
c
b
c
c
b
a
Given an example to show that f is not associative.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 1
For A = {a, b, c}, let f : A × A → A be the closed binary operation
given in the following table.
f
a
b
c
a
b
a
c
b
a
c
b
c
c
b
a
Given an example to show that f is not associative.
Answer
f (f (a, b), c) = f (a, c) = c, while f (a, f (b, c)) = f (a, b) = a, thus,
f is not associative.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 2
Let f : R × R → Z be the closed binary operation defined by
f (a, b) = da + be.
(a) Is f commutatitive?
(b) Is f associative?
(c) Does f have an identity element?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 2
Let f : R × R → Z be the closed binary operation defined by
f (a, b) = da + be.
(a) Is f commutatitive?
(b) Is f associative?
(c) Does f have an identity element?
Answer
(a) For all a, b ∈ R, f (a, b) = da + be = db + ae = f (b, a). Thus,
f is commutative.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 2
Let f : R × R → Z be the closed binary operation defined by
f (a, b) = da + be.
(a) Is f commutatitive?
(b) Is f associative?
(c) Does f have an identity element?
Answer
(a) For all a, b ∈ R, f (a, b) = da + be = db + ae = f (b, a). Thus,
f is commutative.
(b) f (f (3.2, 4.7), 6.4) = f (8, 6.4) = 15, where
f (3.2, f (4.7, 6.4)) = f (3.2, 12) = 16. Thus, f is not
associative.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 2
Let f : R × R → Z be the closed binary operation defined by
f (a, b) = da + be.
(a) Is f commutatitive?
(b) Is f associative?
(c) Does f have an identity element?
Answer
(a) For all a, b ∈ R, f (a, b) = da + be = db + ae = f (b, a). Thus,
f is commutative.
(b) f (f (3.2, 4.7), 6.4) = f (8, 6.4) = 15, where
f (3.2, f (4.7, 6.4)) = f (3.2, 12) = 16. Thus, f is not
associative.
(c) There is no identity element. Consider a = 0.5, then for any
b ∈ R, f (a, b) ∈ Z. Suppose x is the identity element, we have
0.5 = f (0.5, x) ∈ Z, contradicting that 0.5 ∈
/ Z.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 5
Let |A| = 5.
(a) What is |A × A|?
(b) How many functions f : A × A → A are there?
(c) How many closed binary operations are there on A?
(d) How many of these closed binary operations are commutative?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 5
Let |A| = 5.
(a) What is |A × A|?
(b) How many functions f : A × A → A are there?
(c) How many closed binary operations are there on A?
(d) How many of these closed binary operations are commutative?
Answer
(a) 5 × 5 = 25
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 5
Let |A| = 5.
(a) What is |A × A|?
(b) How many functions f : A × A → A are there?
(c) How many closed binary operations are there on A?
(d) How many of these closed binary operations are commutative?
Answer
(a) 5 × 5 = 25
(b) 525 .
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.4 Special Functions
Problem 5
Let |A| = 5.
(a) What is |A × A|?
(b) How many functions f : A × A → A are there?
(c) How many closed binary operations are there on A?
(d) How many of these closed binary operations are commutative?
Answer
(a) 5 × 5 = 25
(b) 525 .
(c) 525 , because every closed binary operation corresponds to a
function of A × A → A.
(d) Because there are 52 = 10 pairs of elements in A, there are
510 commutative closed binary operations.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 1
Larry returns from the laundromat with 12 pairs of socks (each pair
a different color) in a laundry bag. Drawing the socks from the bag
randomly, he will have to draw at most 13 of them to get a matched
pair.
What plays the roles of the pigeons and of the pigeonholes?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 1
Larry returns from the laundromat with 12 pairs of socks (each pair
a different color) in a laundry bag. Drawing the socks from the bag
randomly, he will have to draw at most 13 of them to get a matched
pair.
What plays the roles of the pigeons and of the pigeonholes?
Answer
The socks are the pigeons and the colors are the pigeonholes.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 2
Show that if 8 people are in a room, at least two of them have
birthdays that occur on the same day of the week.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 2
Show that if 8 people are in a room, at least two of them have
birthdays that occur on the same day of the week.
Answer
Follow the Pigeonhole Principle, where 8 people are pigeons and 7
days of a week are pigeonholes.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 3
An auditorium has a seating capacity of 800. How many seats must
be occupied to guarantee that at least two people seated in the
auditorium have the same first and the last initials?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 3
An auditorium has a seating capacity of 800. How many seats must
be occupied to guarantee that at least two people seated in the
auditorium have the same first and the last initials?
Answer
Because there are 262 = 676 pairs of the first and the last initials,
the answer is 676 + 1 = 677.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 10
Let 4ABC be equilateral with AB = 1. Show that if we select 10
points in the interior of this triangle, there must be at least two
points whose distance is less than 31 .
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 10
Let 4ABC be equilateral with AB = 1. Show that if we select 10
points in the interior of this triangle, there must be at least two
points whose distance is less than 31 .
Answer
We can partition the 4ABC into 9 equilateral triangles with side
length 13 . There must exist a small triangle containning two points,
whose distance is definitely less than 13 .
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 11
Let ABCD be a square with AB = 1. Show that if we select five
points in the interior of this square, there are at least two points
whose distance is less than √12 .
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 11
Let ABCD be a square with AB = 1. Show that if we select five
points in the interior of this square, there are at least two points
whose distance is less than √12 .
Answer
We can partition the ABCD into 4 squares with side length 21 . There
must exist a small square containning two points, whose distance is
definitely less than √12 .
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 20
How many times must we roll a single die in order to get the same
score
(a) at least twice?
(b) at least three times?
(c) at least n times for n ≥ 4?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 20
How many times must we roll a single die in order to get the same
score
(a) at least twice?
(b) at least three times?
(c) at least n times for n ≥ 4?
Answer
(a) 7, to guarantee d7/6e = 2.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 20
How many times must we roll a single die in order to get the same
score
(a) at least twice?
(b) at least three times?
(c) at least n times for n ≥ 4?
Answer
(a) 7, to guarantee d7/6e = 2.
(b) 13, to guarantee d13/6e = 3.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 20
How many times must we roll a single die in order to get the same
score
(a) at least twice?
(b) at least three times?
(c) at least n times for n ≥ 4?
Answer
(a) 7, to guarantee d7/6e = 2.
(b) 13, to guarantee d13/6e = 3.
(c) 6(n − 1) + 1, , to guarantee d 6(n−1)+1
e = n.
6
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 22
For m, n ∈ Z+ , prove that if m pigeons occupy n pigeonholes, then
at least one pigeonhole has b m−1
n c + 1 or more pigeons roosting in
it.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.5 The Pigeonhole Principle
Problem 22
For m, n ∈ Z+ , prove that if m pigeons occupy n pigeonholes, then
at least one pigeonhole has b m−1
n c + 1 or more pigeons roosting in
it.
Answer
If not, each pigeonhole contains at most b(m − 1)/nc pigeons, for
a total nb(m − 1)/nc ≤ m − 1 pigeons, contradicting that we have
m pigeons. Therefore, the at least one pigeonhole has b m−1
n c + 1 or
more pigeons roosting in it.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 1
(a) For A = {1, 2, 3 . . . , 7}, how many bijective functions
f : A → A satisfy f (1) 6= 1?
(b) Answer the part (a) where A = {x|x ∈ Z+ , 1 ≤ x ≤ n}, for
some fixed n ∈ Z+ .
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 1
(a) For A = {1, 2, 3 . . . , 7}, how many bijective functions
f : A → A satisfy f (1) 6= 1?
(b) Answer the part (a) where A = {x|x ∈ Z+ , 1 ≤ x ≤ n}, for
some fixed n ∈ Z+ .
Answer
(a) There are 7! bijective functions on A. Among them, there are
6! bijective funcitons satisfy f (1) = 1. Therefore, the answer is
7! − 6! = 6 × 6!.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 1
(a) For A = {1, 2, 3 . . . , 7}, how many bijective functions
f : A → A satisfy f (1) 6= 1?
(b) Answer the part (a) where A = {x|x ∈ Z+ , 1 ≤ x ≤ n}, for
some fixed n ∈ Z+ .
Answer
(a) There are 7! bijective functions on A. Among them, there are
6! bijective funcitons satisfy f (1) = 1. Therefore, the answer is
7! − 6! = 6 × 6!.
(b) In general, there are n! − (n − 1)! = (n − 1) × (n − 1)!
bijective functions.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 4
Let g : N → N be defined by g (n) = 2n. If A = {1, 2, 3, 4} and
f : A → N is given by f = {(1, 2), (2, 3), (3, 5), (4, 7)}, find g ◦ f .
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 4
Let g : N → N be defined by g (n) = 2n. If A = {1, 2, 3, 4} and
f : A → N is given by f = {(1, 2), (2, 3), (3, 5), (4, 7)}, find g ◦ f .
Answer
g ◦ f = g (f (·)) = {(1, 4), (2, 6), (3, 10), (4, 14)}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 7(a)
Let f , g , h : Z → Z be defined by f (x) = x − 1, g (x) = 3x and
0, x is even
h(x) =
1, x is odd
Determine f ◦ g , g ◦ f , g ◦ h, h ◦ g , f ◦ (g ◦ h), (f ◦ g ) ◦ h.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 7(a)
Let f , g , h : Z → Z be defined by f (x) = x − 1, g (x) = 3x and
0, x is even
h(x) =
1, x is odd
Determine f ◦ g , g ◦ f , g ◦ h, h ◦ g , f ◦ (g ◦ h), (f ◦ g ) ◦ h.
Answer
(f ◦ g )(x) = 3x − 1; (g ◦ f )(x) = 3(x − 1);
(g ◦ h)(x) = 0 when x is even, or 3 when x is odd.
(h ◦ g )(x) = 0 when x is even, or 3 when x is odd.
(f ◦ (g ◦ h))(x) = −1 when x is even, or 2 when x is odd.
((f ◦ g ) ◦ h)(x) = −1 when x is even, or 2 when x is odd.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 7(b)
Let f , g , h : Z → Z be defined by f (x) = x − 1, g (x) = 3x and
0, x is even
h(x) =
1, x is odd
Determine f 2 , f 3 , g 2 , g 3 , h2 , h3 , h500 .
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 7(b)
Let f , g , h : Z → Z be defined by f (x) = x − 1, g (x) = 3x and
0, x is even
h(x) =
1, x is odd
Determine f 2 , f 3 , g 2 , g 3 , h2 , h3 , h500 .
Answer
f 2 (x) = x − 2; f 3 (x) = x − 3; g 2 = 9x; g 3 = 27x;
h2 (x) = h(x), h3 (x) = h(x), h500 (x) = h(x).
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 12
If A = {1, 2, 3, 4, 5, 6, 7}, B = {2, 4, 6, 8, 10, 12}, and f : A → B
where f = {(1, 2), (2, 6), (3, 6), (4, 8), (5, 6), (6, 8), (7, 12)}, determine the primage of B1 under f in each of the following case.
(a) B1 = {2}.
(b) B1 = {6}.
(c) B1 = {6, 8}.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 12
If A = {1, 2, 3, 4, 5, 6, 7}, B = {2, 4, 6, 8, 10, 12}, and f : A → B
where f = {(1, 2), (2, 6), (3, 6), (4, 8), (5, 6), (6, 8), (7, 12)}, determine the primage of B1 under f in each of the following case.
(a) B1 = {2}.
(b) B1 = {6}.
(c) B1 = {6, 8}.
Answer
(a) f −1 ({2}) = {a ∈ A|f (a) ∈ {2}} = {a ∈ A|f (a) = 2} = {1}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 12
If A = {1, 2, 3, 4, 5, 6, 7}, B = {2, 4, 6, 8, 10, 12}, and f : A → B
where f = {(1, 2), (2, 6), (3, 6), (4, 8), (5, 6), (6, 8), (7, 12)}, determine the primage of B1 under f in each of the following case.
(a) B1 = {2}.
(b) B1 = {6}.
(c) B1 = {6, 8}.
Answer
(a) f −1 ({2}) = {a ∈ A|f (a) ∈ {2}} = {a ∈ A|f (a) = 2} = {1}.
(b) f −1 ({6}) = {2, 3, 5}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 12
If A = {1, 2, 3, 4, 5, 6, 7}, B = {2, 4, 6, 8, 10, 12}, and f : A → B
where f = {(1, 2), (2, 6), (3, 6), (4, 8), (5, 6), (6, 8), (7, 12)}, determine the primage of B1 under f in each of the following case.
(a) B1 = {2}.
(b) B1 = {6}.
(c) B1 = {6, 8}.
Answer
(a) f −1 ({2}) = {a ∈ A|f (a) ∈ {2}} = {a ∈ A|f (a) = 2} = {1}.
(b) f −1 ({6}) = {2, 3, 5}.
(c) f −1 ({6, 8}) = {2, 3, 4, 5, 6}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 12 Continue
If A = {1, 2, 3, 4, 5, 6, 7}, B = {2, 4, 6, 8, 10, 12}, and f : A → B
where f = {(1, 2), (2, 6), (3, 6), (4, 8), (5, 6), (6, 8), (7, 12)}, determine the primage of B1 under f in each of the following case.
(d) B1 = {6, 8, 10}.
(e) B1 = {6, 8, 10, 12}.
(f) B1 = {10, 12}.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 12 Continue
If A = {1, 2, 3, 4, 5, 6, 7}, B = {2, 4, 6, 8, 10, 12}, and f : A → B
where f = {(1, 2), (2, 6), (3, 6), (4, 8), (5, 6), (6, 8), (7, 12)}, determine the primage of B1 under f in each of the following case.
(d) B1 = {6, 8, 10}.
(e) B1 = {6, 8, 10, 12}.
(f) B1 = {10, 12}.
Answer
(d) f −1 ({6, 8, 10}) = {2, 3, 4, 5, 6}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 12 Continue
If A = {1, 2, 3, 4, 5, 6, 7}, B = {2, 4, 6, 8, 10, 12}, and f : A → B
where f = {(1, 2), (2, 6), (3, 6), (4, 8), (5, 6), (6, 8), (7, 12)}, determine the primage of B1 under f in each of the following case.
(d) B1 = {6, 8, 10}.
(e) B1 = {6, 8, 10, 12}.
(f) B1 = {10, 12}.
Answer
(d) f −1 ({6, 8, 10}) = {2, 3, 4, 5, 6}.
(e) f −1 ({6, 8, 10, 12}) = {2, 3, 4, 5, 6, 7}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 12 Continue
If A = {1, 2, 3, 4, 5, 6, 7}, B = {2, 4, 6, 8, 10, 12}, and f : A → B
where f = {(1, 2), (2, 6), (3, 6), (4, 8), (5, 6), (6, 8), (7, 12)}, determine the primage of B1 under f in each of the following case.
(d) B1 = {6, 8, 10}.
(e) B1 = {6, 8, 10, 12}.
(f) B1 = {10, 12}.
Answer
(d) f −1 ({6, 8, 10}) = {2, 3, 4, 5, 6}.
(e) f −1 ({6, 8, 10, 12}) = {2, 3, 4, 5, 6, 7}.
(f) f −1 ({10, 12}) = {7}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 15
Let A = {1, 2, 3, 4, 5} and B = {6, 7, 8, 9, 10, 11, 12}. How many
functions f : A → B are such that f −1 ({6, 7, 8}) = {1, 2}?
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 15
Let A = {1, 2, 3, 4, 5} and B = {6, 7, 8, 9, 10, 11, 12}. How many
functions f : A → B are such that f −1 ({6, 7, 8}) = {1, 2}?
Answer
Since f −1 ({6, 7, 8}) = {1, 2}, there are three choices for each of f (1)
and f (2), namely 6, 7, or 8. Furthermore, 3, 4, 5 ∈
/ f −1 ({6, 7, 8}) so
3, 4, 5 ∈ f −1 ({9, 10, 11, 12}), and we have four choices for each of
f (3), f (4) and f (5). Therefore, it follows by the rule of product that
there are 32 ×43 = 576 funcitons from A to B where f −1 ({6, 7, 8}) =
{1, 2}.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 20
(a) Given an example of a function f : Z → Z where f is
one-to-one but not onto.
(b) Given an example of a function f : Z → Z where f is onto but
not one-to-one.
(c) Do these examples contradict the Theorem 5.11, described as
follows?
Theorem 5.11 Let f : A → B for finite sets A and B where
|A| = |B|. Then the following statements are equivalent: (i) f
is one-to-one; (b) f is onto; (c) f is invertible.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 20
(a) Given an example of a function f : Z → Z where f is
one-to-one but not onto.
(b) Given an example of a function f : Z → Z where f is onto but
not one-to-one.
(c) Do these examples contradict the Theorem 5.11, described as
follows?
Theorem 5.11 Let f : A → B for finite sets A and B where
|A| = |B|. Then the following statements are equivalent: (i) f
is one-to-one; (b) f is onto; (c) f is invertible.
Answer
(a) f (x) = 2x.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 20
(a) Given an example of a function f : Z → Z where f is
one-to-one but not onto.
(b) Given an example of a function f : Z → Z where f is onto but
not one-to-one.
(c) Do these examples contradict the Theorem 5.11, described as
follows?
Theorem 5.11 Let f : A → B for finite sets A and B where
|A| = |B|. Then the following statements are equivalent: (i) f
is one-to-one; (b) f is onto; (c) f is invertible.
Answer
(a) f (x) = 2x.
(b) f (x) = bx/2c.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 20
(a) Given an example of a function f : Z → Z where f is
one-to-one but not onto.
(b) Given an example of a function f : Z → Z where f is onto but
not one-to-one.
(c) Do these examples contradict the Theorem 5.11, described as
follows?
Theorem 5.11 Let f : A → B for finite sets A and B where
|A| = |B|. Then the following statements are equivalent: (i) f
is one-to-one; (b) f is onto; (c) f is invertible.
Answer
(a) f (x) = 2x.
(b) f (x) = bx/2c.
(c) No, Z is not a finite set.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 21
Let f : Z → N be defined by
2x − 1, if x > 0
f (x) =
−2x,
if x ≤ 0
(a) Prove that f is one-to-one and onto.
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 21
Let f : Z → N be defined by
2x − 1, if x > 0
f (x) =
−2x,
if x ≤ 0
(a) Prove that f is one-to-one and onto.
Answer
(a) When x ≥ 0, f (x) is odd. When x < 0, f (x) is even.
Therefore, f is one-to-one.
Let n ∈ N. If n is even, then (−n/2) < 0, (−n/2) ∈ Z, and
f (−n/2) = n. If n is odd, then (n + 1)/2 > 0, (n + 1)/2 ∈ Z,
and f ((n + 1)/2) = n. Therefore, f is onto.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 21 Continue
Let f : Z → N be defined by
2x − 1, if x > 0
f (x) =
−2x,
if x ≤ 0
(b) Determine f −1 .
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.6 Function Composition and Inverse Functions
Problem 21 Continue
Let f : Z → N be defined by
2x − 1, if x > 0
f (x) =
−2x,
if x ≤ 0
(b) Determine f −1 .
Answer
(b) f −1 : N → Z is defined as
(x + 1)/2 x is odd
−1
f (x) =
−x/2
x is even
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 1
Determine the best “big-Oh” form for each of the following functions
f : Z+ → R.
(a) f (n) = 3n + 7
(b) f (n) = 3 + sin(1/n)
(c) f (n) = n3 − 5n2 + 25n − 165
(d) f (n) = 5n2 + 3n log2 n
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 1
Determine the best “big-Oh” form for each of the following functions
f : Z+ → R.
(a) f (n) = 3n + 7
(b) f (n) = 3 + sin(1/n)
(c) f (n) = n3 − 5n2 + 25n − 165
(d) f (n) = 5n2 + 3n log2 n
Answer
(a) f ∈ O(n)
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 1
Determine the best “big-Oh” form for each of the following functions
f : Z+ → R.
(a) f (n) = 3n + 7
(b) f (n) = 3 + sin(1/n)
(c) f (n) = n3 − 5n2 + 25n − 165
(d) f (n) = 5n2 + 3n log2 n
Answer
(a) f ∈ O(n)
(b) f ∈ O(1)
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 1
Determine the best “big-Oh” form for each of the following functions
f : Z+ → R.
(a) f (n) = 3n + 7
(b) f (n) = 3 + sin(1/n)
(c) f (n) = n3 − 5n2 + 25n − 165
(d) f (n) = 5n2 + 3n log2 n
Answer
(a) f ∈ O(n)
(b) f ∈ O(1)
(c) f ∈ O(n3 )
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 1
Determine the best “big-Oh” form for each of the following functions
f : Z+ → R.
(a) f (n) = 3n + 7
(b) f (n) = 3 + sin(1/n)
(c) f (n) = n3 − 5n2 + 25n − 165
(d) f (n) = 5n2 + 3n log2 n
Answer
(a) f ∈ O(n)
(b) f ∈ O(1)
(c) f ∈ O(n3 )
(d) f ∈ O(n2 )
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 1 Continue
Determine the best “big-Oh” form for each of the following functions
f : Z+ → R.
(e) f (n) = n2 + (n − 1)3
(f) f (n) =
n(n+1)(n+2)
(n+3)
(g) f (n) = 2 + 4 + 6 + . . . + 2n
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 1 Continue
Determine the best “big-Oh” form for each of the following functions
f : Z+ → R.
(e) f (n) = n2 + (n − 1)3
(f) f (n) =
n(n+1)(n+2)
(n+3)
(g) f (n) = 2 + 4 + 6 + . . . + 2n
Answer
(e) f ∈ O(n3 )
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 1 Continue
Determine the best “big-Oh” form for each of the following functions
f : Z+ → R.
(e) f (n) = n2 + (n − 1)3
(f) f (n) =
n(n+1)(n+2)
(n+3)
(g) f (n) = 2 + 4 + 6 + . . . + 2n
Answer
(e) f ∈ O(n3 )
(f) f ∈ O(n2 )
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 1 Continue
Determine the best “big-Oh” form for each of the following functions
f : Z+ → R.
(e) f (n) = n2 + (n − 1)3
(f) f (n) =
n(n+1)(n+2)
(n+3)
(g) f (n) = 2 + 4 + 6 + . . . + 2n
Answer
(e) f ∈ O(n3 )
(f) f ∈ O(n2 )
(g) f ∈ O(n2 )
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 11
The following is analogous to the “big-Oh”.
For f , g : Z+ → R we say that f is of order at least g if there exist
constants M ∈ R+ and k ∈ Z+ such that |f (n)| ≥ M|g (n)| for all
n ∈ Z+ where n ≥ k. In this case we write f ∈ Ω(g ) and says f is
“big Omega of” g . So Ω(g ) represents the set of all functions with
domain Z+ and codomain R that dominate g .
Suppose that f , g , h : Z+ → R, where f (n) = 5n2 + 3n, g (n) = n2 ,
h(n) = n, for all n ∈ Z+ . Prove that
(a) f ∈ Ω(g )
(b) g ∈ Ω(f )
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 11
The following is analogous to the “big-Oh”.
For f , g : Z+ → R we say that f is of order at least g if there exist
constants M ∈ R+ and k ∈ Z+ such that |f (n)| ≥ M|g (n)| for all
n ∈ Z+ where n ≥ k. In this case we write f ∈ Ω(g ) and says f is
“big Omega of” g . So Ω(g ) represents the set of all functions with
domain Z+ and codomain R that dominate g .
Suppose that f , g , h : Z+ → R, where f (n) = 5n2 + 3n, g (n) = n2 ,
h(n) = n, for all n ∈ Z+ . Prove that
(a) f ∈ Ω(g )
(b) g ∈ Ω(f )
Answer
(a) Let M = 1 and k = 1.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 11
The following is analogous to the “big-Oh”.
For f , g : Z+ → R we say that f is of order at least g if there exist
constants M ∈ R+ and k ∈ Z+ such that |f (n)| ≥ M|g (n)| for all
n ∈ Z+ where n ≥ k. In this case we write f ∈ Ω(g ) and says f is
“big Omega of” g . So Ω(g ) represents the set of all functions with
domain Z+ and codomain R that dominate g .
Suppose that f , g , h : Z+ → R, where f (n) = 5n2 + 3n, g (n) = n2 ,
h(n) = n, for all n ∈ Z+ . Prove that
(a) f ∈ Ω(g )
(b) g ∈ Ω(f )
Answer
(a) Let M = 1 and k = 1.
(b) Let M = 0.1 and k = 1.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 11 Continue
The following is analogous to the “big-Oh”.
For f , g : Z+ → R we say that f is of order at least g if there exist
constants M ∈ R+ and k ∈ Z+ such that |f (n)| ≥ M|g (n)| for all
n ∈ Z+ where n ≥ k. In this case we write f ∈ Ω(g ) and says f is
“big Omega of” g . So Ω(g ) represents the set of all functions with
domain Z+ and codomain R that dominate g .
Suppose that f , g , h : Z+ → R, where f (n) = 5n2 + 3n, g (n) = n2 ,
h(n) = n, for all n ∈ Z+ . Prove that
(c) f ∈ Ω(h)
(d) h ∈
/ Ω(f )
Answer
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 11 Continue
The following is analogous to the “big-Oh”.
For f , g : Z+ → R we say that f is of order at least g if there exist
constants M ∈ R+ and k ∈ Z+ such that |f (n)| ≥ M|g (n)| for all
n ∈ Z+ where n ≥ k. In this case we write f ∈ Ω(g ) and says f is
“big Omega of” g . So Ω(g ) represents the set of all functions with
domain Z+ and codomain R that dominate g .
Suppose that f , g , h : Z+ → R, where f (n) = 5n2 + 3n, g (n) = n2 ,
h(n) = n, for all n ∈ Z+ . Prove that
(c) f ∈ Ω(h)
(d) h ∈
/ Ω(f )
Answer
(c) Let M = 1 and k = 1.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 11 Continue
The following is analogous to the “big-Oh”.
For f , g : Z+ → R we say that f is of order at least g if there exist
constants M ∈ R+ and k ∈ Z+ such that |f (n)| ≥ M|g (n)| for all
n ∈ Z+ where n ≥ k. In this case we write f ∈ Ω(g ) and says f is
“big Omega of” g . So Ω(g ) represents the set of all functions with
domain Z+ and codomain R that dominate g .
Suppose that f , g , h : Z+ → R, where f (n) = 5n2 + 3n, g (n) = n2 ,
h(n) = n, for all n ∈ Z+ . Prove that
(c) f ∈ Ω(h)
(d) h ∈
/ Ω(f )
Answer
(c) Let M = 1 and k = 1.
(d) Suppose h ∈ Ω(f ), i.e., there exists such M and k. Then we
have 0 < M ≤ 5n2n+3n = 1, i.e., M cannot be a positive
constant. Threfore, h ∈
/ Ω(f ).
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 14
For f , g : Z+ → R, we say f is “big Theta of” g , and write f ∈
Θ(g ), when there exists constant m1 , m2 ∈ R+ and k ∈ Z+ such
that m1 |g (n)| ≤ |f (n)| ≤ m2 |g (n)|, for all n ∈ Z+ where n ≥ k.
Prove that f ∈ Θ(g ) if and only if f ∈ Ω(g ) and f ∈ O(g ).
Answer
When f ∈ Θ(g ), ∃m1 , m2 ∈ R+ ∃k ∈ Z+ ∀n ≥ km1 |g (n)| ≤
|f (n)| ≤ m2 |g (n)|. Therefore, ∃m1 ∈ R+ ∃k ∈ Z+ ∀n ≥
km1 |g (n)| ≤ |f (n)|, i.e., f ∈ Ω(g ). Similarly, we have f ∈ O(g ).
Conversely, f ∈ Ω(g ) implies that ∃m1 ∈ R+ ∃k1 ∈ Z+ ∀n ≥
k1 m1 |g (n)| ≤ |f (n)|; f ∈ O(g ) implies that ∃m2 ∈ R+ ∃k2 ∈
Z+ ∀n ≥ k2 |f (n)| ≤ m2 |g (n)|. Let k = max{k1 , k2 }, we have
∃m1 , m2 ∈ R+ ∃k ∈ Z+ ∀n ≥ km1 |g (n)| ≤ |f (n)| ≤ m2 |g (n)|, i.e.,
f ∈ Θ(g ).
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 16
(a) Let f : Z+ → R where f (n) =
(b) Let f : Z+ → R where g (n) =
Pn
Pi=1
n
i. Prove that f ∈ Θ(n2 ).
Prove that g ∈ Θ(n3 ).
P
(c) For t ∈ Z+ , let h : Z+ → R where h(n) = ni=1 i t . Prove that
f ∈ Θ(nt+1 ).
Answer
i=1 i
2.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 16
(a) Let f : Z+ → R where f (n) =
(b) Let f : Z+ → R where g (n) =
Pn
Pi=1
n
i. Prove that f ∈ Θ(n2 ).
Prove that g ∈ Θ(n3 ).
P
(c) For t ∈ Z+ , let h : Z+ → R where h(n) = ni=1 i t . Prove that
f ∈ Θ(nt+1 ).
i=1 i
2.
Answer
(c) f (n) =
n(n+1)
.
2
Let m1 = 0.2, m2 = 2 and k = 1.
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 16
(a) Let f : Z+ → R where f (n) =
(b) Let f : Z+ → R where g (n) =
Pn
Pi=1
n
i. Prove that f ∈ Θ(n2 ).
Prove that g ∈ Θ(n3 ).
P
(c) For t ∈ Z+ , let h : Z+ → R where h(n) = ni=1 i t . Prove that
f ∈ Θ(nt+1 ).
i=1 i
2.
Answer
(c) f (n) =
n(n+1)
. Let m1 = 0.2, m2 = 2 and k = 1.
P
(d) f (n) ≤ i=1 n2 = n3 . f (n) ≥ ni=dn/2e i 2 ≥
Pn
2
2
3
i=dn/2e dn/2e = d(n + 1)/2edn/2e > n /8. Let k = 1,
m1 = 1/8 and m2 = 1.
Pn2
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.7 Computational Complexity
Problem 16
(a) Let f : Z+ → R where f (n) =
(b) Let f : Z+ → R where g (n) =
Pn
Pi=1
n
i. Prove that f ∈ Θ(n2 ).
Prove that g ∈ Θ(n3 ).
P
(c) For t ∈ Z+ , let h : Z+ → R where h(n) = ni=1 i t . Prove that
f ∈ Θ(nt+1 ).
i=1 i
2.
Answer
(c) f (n) =
n(n+1)
. Let m1 = 0.2, m2 = 2 and k = 1.
P
(d) f (n) ≤ i=1 n2 = n3 . f (n) ≥ ni=dn/2e i 2 ≥
Pn
2
2
3
i=dn/2e dn/2e = d(n + 1)/2edn/2e > n /8. Let k = 1,
m1 = 1/8 and m2 = 1.
P
P
(e) f (n) ≤ ni=1 nt = nt+1 . f (n) ≥ ni=dn/2e i t ≥
Pn
t
t
t+1 . Let k = 1,
i=dn/2e dn/2e = d(n + 1)/2edn/2e > (n/2)
m1 = (1/2)t+1 and m2 = 1.
Pn2
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.8 Analysis of Algorithms
Problem 1 (a)
Define the time-complexity function f (n) to be the number of times
the statement sum = sum + 1 is executed. Given the following
program fragment, determine the best “big-Oh” form for f .
sum=0;
for i=1 to n do
for j=1 to n do
sum=sum+1;
Answer
f (n) = n2 , so f ∈ O(n2 ).
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.8 Analysis of Algorithms
Problem 1 (b)
Define the time-complexity function f (n) to be the number of times
the statement sum = sum + 1 is executed. Given the following
program fragment, determine the best “big-Oh” form for f .
sum=0;
for i=1 to n do
for j=1 to n*n do
sum=sum+1;
Answer
f (n) = n3 , so f ∈ O(n3 ).
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.8 Analysis of Algorithms
Problem 1 (c)
Define the time-complexity function f (n) to be the number of times
the statement sum = sum + 1 is executed. Given the following
program fragment, determine the best “big-Oh” form for f .
sum=0;
for i=1 to n do
for j=i to n do
sum=sum+1;
Answer
f (n) = n + (n − 1) + . . . + 1 =
n(n+1)
,
2
so f ∈ O(n2 ).
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.8 Analysis of Algorithms
Problem 1 (d)
Define the time-complexity function f (n) to be the number of times
the statement sum = sum + 1 is executed. Given the following
program fragment, determine the best “big-Oh” form for f .
sum=0;
i = n;
while i¿0 do
sum = sum + 1;
i = bi/2c;
Answer
f ∈ O(log2 n)
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.8 Analysis of Algorithms
Problem 1 (e)
Define the time-complexity function f (n) to be the number of times
the statement sum = sum + 1 is executed. Given the following
program fragment, determine the best “big-Oh” form for f .
sum=0;
for i=1 to n do
j = n;
while j ¿ 0 do
sum = sum + 1;
j = bj/2c;
Answer
f ∈ O(n log2 n)
CSC 10400: Discrete Mathematical Structures Recitation Chapter 5
Chapter 5: Relations and Functions
Section 5.8 Analysis of Algorithms
Problem 5
The following pseudocode procedure can be used to evaluate the
polynomial.
product=1; value = a0 ;
for i=1 to n do
product=product*x;
value=value+ai *product;
For the polynomial 8−10x +7x 2 −2x 3 +3x 4 +12x 5 , we have n = 5,
a0 = 8, a1 = −10, a2 = 7, a3 = −2, a4 = 3, and a5 = 12.
(a) How many additions and how many multiplications occur to
evaluate this polynomial?
(b) How many additions and how many multiplications occur to
evaluate the general polynomial a0 + a1 x + a2 x 2 + . . . + an x n ?
Answer
(a) 5 additions and 10 multiplications.
(b) n additions and 2n multiplications.