You are on page 1of 9

COMSATS University, Islamabad

Islamabad Campus
Department of Computer Science

Read before Attempt


Assignment No. 2A
Course code and Title: CSC102, DISCRETE STRUCTURES
Instructor: Tanveer Ahmed Class: BCS1A, BCS 1B, BCS 2A
Assigned Date: May 21, 2023 Due Date: May 29, 2023
CLO-3: Perform the operations associated with sets, functions, and relations.
Instructions:
1. This is an individual assignment. You will submit your work individually through your logins
(course portal)
2. Try to get the concepts, consolidate your concepts and ideas from these questions.
3. You should concern recommended books for clarify your concepts as handouts are not
sufficient.

4. Read Chapter No 2, 5, and 8 to solve this assignment.


5. Try to make solution by yourself and protect your work from other students. If I found

the solution files of some students are same then I will reward zero marks to all
those students.
6. The deadline for this assignment is May 29, 2023. This deadline will not be extended.

Spring 2023 Page 1


FUNCTION
Question # 1 (Well defined functions)
i) Determine whether these are functions. Explain.

ii)
iii)

Question # 2 (Finding functional value at given point)


For each of the following functions, determine the images of the given values.
i)
Remark: Recall that, without parentheses, the notation “mod” means the binary operation mod.

ii)
Question # 2A(Designing a function from a given real life scenario)
A town in Islamabad charges each household a minimum of Rs.75 for upto 4000 cubic feet(ft3) of water every
6 months. In addition, each household has to pay 60 paisa for every 100 ft3 of water in excess of 4000 ft3.
Express the water bill f(x) as a function of number of cubic feet of water x used for 6 months.
Question # 2B(Writing alternative definitions using Predicate logic)
a) Write the definition of “one-to-one” using logical notation (i.e., use  , ∃, etc.).
b) Use De Morgan’s laws of logic to negate the definition of “one-to-one.”
c) Write the definition of “onto” using logical notation (i.e., use  , ∃, etc.).
d) Use De Morgan’s laws of logic to negate the definition of “onto.”
Question # 3 (Computing functional value and prove its properties)
Let f be the function from X = {0, 1, 2, 3, 4} to X defined by
f (x) = 4x mod 5.
i. Write f as a set of ordered pairs and draw the arrow diagram of f.
ii. Is f one-to-one? Is f onto?
Question # 4 (Design a function and prove its properties)
Let X = {a, b, c}. Define a function S from P(X) to the set of bit strings of length 3 as follows:
Let Y ⊆ X. If a ∈ Y, set s1 = 1; if a  Y, set s1 = 0. If b ∈ Y, set s2 = 1; if b  Y, set s2 = 0. If c ∈ Y, set s3 = 1;
if c  Y, set s3 = 0. Define S(Y) = s1s2s3.
i. What is the value of S({a, c})?
ii. What is the value of S(∅)?
iii. What is the value of S(X)?
iv. Prove that S is one-to-one.
v. Prove that S is onto.
Question # 5 (Computing functional value)

Spring 2023 Page 2


𝑎+𝑏+1 𝑎+𝑏+1
A function f is defined such that f(1)=5/2 and f(a+b)=( 𝑎+1 ) f(a)+( 𝑏+1 )f(b)+a+2, where a and b are natural
number
𝑓(𝑎+1) 𝑓(𝑎)
i) Find the value of 𝑎+2 − 𝑎+1
ii) Hence find the value of f(2)
Question # 6 (Computing inverse and its functional value)
i) Given that f(x)= ax+b, f(1)= 1 f-1 (5)= 2, find the value of a and of b hence find f-1(x) and evaluate f-1(7)
1
and f-1(-52)
3x−7
ii) The function f is defined by f(x) = 8
5
a. Evaluate f(-2) and f(2 6)
b. Find the value of x for which f(x)=5
Question # 7 (Composition of a function)
Let f and g be functions from the positive integers to the positive integers defined by the equations
f (n) = n2, g(n) = 2n.
Find the compositions:
i. f◦f
ii. g ◦ g,
iii. f ◦ g,
iv. g◦f.
Question # 8 (Hybrid or Piecewise function and its properties, inverse, and composition)
i) Is function defined by

One-to One?
ii) Show that the function defined by

is One-to One.
iii) Draw the graph of the piecewise-defined functions defined by

Is h onto function? Explain.


iv) Draw the graph of the piecewise-defined functions defined by

Is k onto function? Explain.


v) Consider the following two functions; function a and function b whose graphs are given below.

Spring 2023 Page 3


These functions are onto but not one-to-one. Construct a one-to-one and onto function from [1,3] to [2,5].
vi) The functions are defined by

Determine f ∘ g
vii) Consider the following two piecewise functions defined by

Determine g ∘ f. Hence determine (g ∘ f)(2) and (g ∘ f)(5)

viii) Find the inverse function of defined by Be sure


you describe g-1 properly.

Sequence and Series


Question # 9
i) Evaluate each of the sum

Spring 2023 Page 4


ii) Evaluate each of the sum.

Where is defined as follows

Question # 7
Rewrite each sum using the summation notation.

Spring 2023 Page 5


Question # 8(Recursively define functions)
A. Ackermann’s function is defined recursively as follows, where ∈ 𝑤:

i) Compute the following.

ii) Prove each for n > 0

iii) Predict a formula for A(3, n)


B. Stirling numbers of the second kind, denoted by S(n,r) are defined recursively as follows, where n, r
∈ ℕ:

i) Compute each Stirling number.

1. S(2,2) 2. S(5,2)
C. The gcd of two non-zero positive numbers can be defined recursively as follows:

Using this definition, compute the gcd of each pair of integers.

D. Consider the following function f, invited by Johm McCarthy (one of the father of Artificial
Intelligence).

Compute the following.

Spring 2023 Page 6


E. The nth Lucas number Ln, named after the French mathematician Francois- Edouard-Anatole Lucas, is
defined recursively as follows:

Compute the first six Lucas numbers.


F. Let t be a function defined by

Where 𝑎, 𝑏 ∈ ℝ+ .Evaluate t(5) and t(6)


G. Let 𝑎, 𝑏, 𝑘 ∈ ℕ, 𝑏 ≥ 2, 𝑎𝑛𝑑 𝑛 = 𝑏 𝑘 . Consider the function f defined by𝑓(𝑛) = 𝑎𝑓(𝑛⁄𝑏) + g(n). Show
that 𝑓(𝑛) = 𝑎𝑘 𝑓(1) + ∑𝑘−1 𝑖
𝑖=0 𝑎 g(n/b )
i

Question # 9(Recursively define sequence)


A. Let an denote the number of n-bit words containing no two consecutive 1’s. Define an recursively.
B. Let an denote the number of subsets of the set S = {1,2, 3,…...,n} that do not contain consecutive integers, where
n ≥ 0. When n = 0, S = ∅. Find an explicit recursive formula for an.
C. A robot can take steps of 1 meter or 2 meters. Let W(n) denotes all possible ways the robot can walk n
meters (with order taken into account). Define recursive formula for W(n).
D. A robot can take steps of 1 meter ,2 meters or 3 meters. Let W(n) denotes all possible ways the robot can
walk n meters (with order taken into account). Define recursive formula for W(n).
E. The side of the equilateral triangle in following figure is n units long. Let an denote the number of
triangles pointing north.

F. Square pyramidal numbers Sn are positive integers that can be represented by pyramidal shapes, where the base
is square. The first four square pyramidal numbers are 1, 5, 14, and 30; see below figure.

Spring 2023 Page 7


Define recursive formula for Sn/

G. Triangular pyramidal numbers Tn (or tetrahedral numbers) are positive integers that can be represented
by triangular pyramidal shapes. The first four tetrahedral numbers are 1, 4, 10, and 20; see below figure.
Define recursive formula for Tn/

Question # 9( Solving a recurrence relation)


A. Using the iterative method, predict a solution to each recurrence relation satisfying the given initial condition.

Spring 2023 Page 8


B. Define a sequence s as
rn = 3· 2n − 4· 5n, n ≥ 0.
Prove that {rn} satisfies
rn = 7rn−1 − 10rn−2, n ≥ 2.

Spring 2023 Page 9

You might also like