Assignment 1 Final
Assignment 1 Final
SEMESTER 2020/2021
GROUP: GROUP B2
Let
M=Male students
F=Female students
M={A,B,C,D}
F={E,F,G,H}
Solution
Possibility of the matchup
= (MxF)
=
{(A,E),(A,F),(A,G),(A,H),(B,E),(B,F),(B,G),(B,H),(C,E),(C,F)
,(C,G),(C,H),(D,E),(D,F),(D,G),(D,H),}
=Therefore , the possibility is 16
References
1. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
2. Cunningham, Daniel W. (2016). Set theory : a first course.
New York NY : Cambridge University Press.
2.https://www.mathstopia.net/sets/cartesian-product
3.
Question 2: Sets
In a class of 40 students, each student must play at least one outdoor
game basketball, football and badminton. 14 play basketball, 20 play
football and 28 play badminton. 6 play basketball and football, 14
play badminton and football and 4 play basketball, football and
badminton. Find the number of students who play
(i) badminton and basketball.
(ii) badminton and basketball but not football. Mary
Solution
Let A be the set of students who play basketball
B be the set of students who play football
C be the set of students who play badminton
Therefore, We are given n(A ∪ B ∪ C) = 40,
n(A) = 14 n(B) = 20 n(C) = 28,
n(A ∩ B) = 6, n(C ∩ B) = 14 n(A ∩ B ∩ C) = 4
We have
n(A ∪ B ∪ C) = n(A) + n(B) + n(C) - n(A ∩ B) - n(B ∩ C) - n(C ∩
A) + n(A ∩ B ∩ C)
Therefore, 40 = 14 + 20 + 28 - 6 - 14 - n(C ∩ A) + 4
40 = 46 - n(C ∩ A)
n(C ∩ A) = 46 - 40
n(C ∩ A) = 6
Therefore, number of students who play basketball and badminton are
6.
Also, number of students who play basketball, badminton and not
football.
= n(C ∩ A) - n(A ∩ B ∩ C)
=6–4
=2
Therefore, number of students who play basketball, badminton and
not football are 2.
References
1. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
2. Cunningham, Daniel W. (2016). Set theory : a first course. New
York NY : Cambridge University Press.
Question 3: Set Operations
In USM , There are 218 student, 158 people can s and 83 can speak
Mandarin .
The questions is :
a)how many can speak English only?
b)and how many can speak Mandarin only?
c)and how many can speak both English and Mandarin ?
Solution
Let
M be the set of people who speak English.
N be the set of people who speak Mandarin
.
M - N be the set of people who speak English and not Mandarin.
N - M be the set of people who speak Mandarin and not English.
M ∩ N be the set of people who speak both Mandarin and English.
Given,
n(M) = 158 n(N) = 83 n(M ∪ N) = 218
Now, n(M ∩ N) = n(M) + n(N) - n(M ∪ N)
= 158 + 83 - 218
= 23
Therefore, Number of persons who speak both Mandarin and English
= 23
n(M) = n(M - N) + n(M ∩ N)
n(M - N) = n(M) - n(M ∩ N )
=158-23
= 135
References
1. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-
Hill Education.
2. Cunningham, Daniel W. (2016). Set theory : a first course.
New York NY : Cambridge University Press.
Question 4: Set Operations
There are 3 groups of futsal team in USM Football Club , The set that
were given is the number of their jersey number that the team wear
during the game.
Solution
a) A-B= {21, 22, 23, 24, 25}
All elements in A excluding all element in B.
b) B-C= {15, 17, 21}
All elements in B excluding all element in C.
c) C-A= {17, 19,23,25, 28}
All elements in C excluding all element in A.
References
1. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
2. Cunningham, Daniel W. (2016). Set theory : a first course. New
York NY : Cambridge University Press.
Question 5: Functions
Solution
f 3a 3 f b f f a b ①
Substitute a 0 into ①
f 0 3 f b f f b ②
Substitute a 1 into ①
f 3 3 f b f f b 1 ③
Replace b with b 1 in ②
f 0 3 f b 1 f f b 1 ④
f 0 3 f b 1 f 3 3 f b
Rearrange to get :
f 3 f 0
f b 1 f b
3
The expression shows that the difference of consecutive terms is
always a constant, which implies that f(x) is an arithmetic progression.
Let f ( x) mx n
m 2 3m
m 2 3m 0
mm 3 0
m 0, m 3
When m 0 , from ⑤,
3a0 3b0 3n a0 b0 0 n
2 2
n0
f ( x) 3x 2016
Answer:
f (2019)
3(2019) 2016
8073
References
1. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
2. Keith Devlin. (2016). Sets, functions, and logic: an introduction
to abstract mathematics. (3rd edn). New York NY : Cambridge
University Press.
Question 6: Functions(composite function)
Functions g and h are given by
Solution
1. Let An = value of the house after n months
2. Find the recurrence solution for An
An = An-1 + (0.03/12)An-1
= An-1(0.03/12 + 1)
= 1.0025An-1
3. Solve the recurrence relation, An
A1 = 1.0025A0
A2 = 1.0025A1
= 1.0025 (1.0025A0)
= (1.0025)2 A0
A3 = 1.0025A2
= 1.0025 [ (1.0025)2 A0 ]
= (1.0025)3 A0
:
An = (1.0025)n Ao
4. Substitute A0 into the recurrence relation, An
Ao = 200,000
An = (1.0025)n Ao
An = (1.0025)n 200,000
5. Find the price of house after 15 months
An = (1.0025)n 200,000
A15 = (1.0025)15 200,000
= 207,632.68
Therefore, the price of the house after 15 months is $207,632.68.
References
1. Grigorieva, E. (2016). Introduction to Sequences and Series.
Methods of Solving Sequence and Series Problems (1st ed., pp.1-65).
Switzerland, Germany: Birkhauser
2. Little, H.C., Teo, K.L. & Brunt, V.B. (2015). Series. Real Analysis
via Sequences and Series (pp. 109-175). New York, NY: Springer-
Verlag
Question 8: Sequences and Summations
Solve .
Solution
=
= t
= t
= ͻ
=3
References
1. Grigorieva, E. (2016). Introduction to Sequences and Series.
Methods of Solving Sequence and Series Problems (1st ed., pp.1-65).
Switzerland, Germany: Birkhauser
2. Little, H.C., Teo, K.L. & Brunt, V.B. (2015). Series. Real Analysis
via Sequences and Series (pp. 109-175). New York, NY: Springer-
Verlag
Solution
From the definition : the relationship form A to B is One To One due
to |A| ≤ |B|
From the definition : the relationship form B to C is One To One due
to |B| ≤ |C|
Finally |A| ≤ |C
References
1. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
2. Cunningham, Daniel W. (2016). Set theory : a first course. New
York NY : Cambridge University Press.
Question 10: Cardinality of Sets
A and B are two uncountable sets. Hence, show that
a) A − B is finite.
b) A ∩ B is finite.
Solution
a) For example,
set A = R (real numbers) is uncountable
set B = R – {0}(nonzero real numbers) is uncountable
Definition h: complement of B with respect to A.
Hence,
h t
Since the set {0} contains only 1 element,
the set {0} is finite and thus h is finite as well.
b) For example,
set A = ∪ tt (nonnegative real numbers) is
uncountable
set B = ∪ tt (nonpositive real numbers) is
uncountable
Definition h: The intersection of sets A and B.
Hence,
h ∪ tt ∪ tt t
Since the set {0} contains only 1 element,
the set {0} is finite and thus h is finite as well.
References
1. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
2. Cunningham, Daniel W. (2016). Set theory : a first course. New
York NY : Cambridge University Press.
Question 11: Matrices
Find X such that X= BA+3B while A and B are
Solution
X = BA + 3B
=
=
ͻ ͻ ͻ
= ͻ ͻ
ͻ ͻ ͻ
= ͻ
References
1. Gentle J.E. (2017). Matrix Algebra: Theory, Computations and
Applications in Statistics (2nd ed.). Switzerland, Germany: Springer
2. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
Question 12: Matrices
Find An for all positive integers n, if
A=
Solution
1. A[2] = A A=
2. A[3] = A[2] A=
3. A[4] = A[3] A=
Solution
1. Sort all jobs in decreasing order of profit.
2. Iterate on jobs in decreasing order of profit. For each job , do the
following :
a) Find a time slot i, such that slot is empty and i < deadline and
i is greatest. Put the job in this slot and mark this slot filled.
b) If no such i exists, then ignore the job.
Pseudocode:
procedure jobs (s0, s1, …, sn: slots of jobs, r0, r 1, …, rn: results; n:a
positive integer)
for i:= 0 to n
sloti = false [Initialize all slots to be free]
for j:= min(n, arr[i].dead)-1 to 0
if slot[j] is false, then
resultj = I [Add this job to result
slotj = true [Make this slot occupied]
break
Reference
1) Job Sequencing Problem (2020, November 4). Retrieved from
www.geeksforgeeks.org/job-sequencing-problem/.
2.) Bubble Sort Problems. Retrieved from
https://www.sparknotes.com/cs/sorting/bubble/problems/
Question 14: Algorithms
Trace the operation of bubble sort on the following list: 4, 8, 3, 5, 6
Solution
The successive configurations of the list are as follows:
First pass:
4, 8, 3, 5, 6 The starting configuration
4, 8, 3, 5, 6 4 < 8, so no swap is necessary
4, 3, 8, 5, 6 Swap the 3 and the 8 because 8 > 3
4, 3, 5, 8, 6 Swap the 5 and the 8 becuase 8 > 5
4, 3, 5, 6, 8 Swap the 6 and the 8 because 8 > 6. This is the end
of the first pass. Notice how the 8 has "bubbled" up
to the top of the list.
Second pass:
3, 4, 5, 6, 8 Swap the 3 and the 4 because 4 > 3. The list is now
in sorted order; the algorithm will detect this on the
next pass through the list when it makes no swaps.
Let a1 = 4, a2 = 8, a3 = 3, a4 = 5and a5 = 6
procedure bubblesort (a1,…,an: real numbers with n≥ 2)
procedure bubblesort (4, 8, 3, 5, 6)
for i:= 1 to n−1
for j:= 1 to n−i
if aj > aj+1 then interchange aj and aj+1
{a1, … , an is now in increasing order}
References
1) Job Sequencing Problem (2020, November 4). Retrieved from
www.geeksforgeeks.org/job-sequencing-problem/.
2.) Bubble Sort Problems. Retrieved from
https://www.sparknotes.com/cs/sorting/bubble/problems/
Question 15: The Growth of Functions (Big-O
Notation)
Show that is O(x).
Solution
Given O(x), thus g(x) = x in the definition of Big-O Notation.
f(x) =
x -2 (quotient)
x+2 ) x2 +2
-x - x
2
- x +2
x+4
6 (remainder)
Thus, we can rewrite the given fraction as:
ͻ
f(x) = = (x - 2) +
<x+6
<x+x
= 2x
= 2|x|
Thus, we need to choose C to be at least 2. Let us then take
C = 2.
By the definition of Big-O Notation, f(x) = O(x) with k = 6 and C = 2.
References
1. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
2. Thomas H. Cormen. (2009). Introduction to Algorithms. (Third
Edition). England, London: Massachusetts Institute of
Technology.
Question 16: The Growth of Functions (Big-Omega
Notation)
t ͻ ͻ t ͻ ͻ
Show that is Ω( .
Solution
t ͻ ͻ t
th
For convenience sake, let k1 = k2 = 1. For x >1
and y > 1, we then obtain:
th | t ͻ ͻ t
| | |
t ͻ ͻ t
=
t ͻ ͻ ͻ t
Since x > 1 and y > 1, we know t t and
.
ͻ ͻ ͻ ͻ ͻ ͻ
>
ͻ ͻ
=3
ͻ ͻ|
= 3|
C then needs to be at most 3, thus let us take C= 3.
By the definition of Big-Omega Notation,
t ͻ ͻ t ͻ ͻ
th is Ω( with the constants C = 3,
k1= 1and k2 = 1.
References
1.Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
2.Thomas H. Cormen. (2009). Introduction to Algorithms. (Third
Edition). England, London: Massachusetts Institute of Technology.
Question 17: Complexity Of Algorithms
The time complexity of an algorithm quantifies the amount of time
taken by an algorithm to
run as a function of the length of the input , therefore the least number
of multiplications of integers is important to minimize the time
complexity of an algorithm
Solution
Given
M1 = 60x40
M2 = 40x80
M3 = 80x20
There are two possible ways to multiply it , which is
Case 1 : M1x(M2xM3)
Case 2 : (M2xM1)xM3
Case 1:
M2xM3=(40x80x20)=64000 multiplications of (40x20 Matrix)
Then M1x(M2xM3) = (60x40x20)=48000
Therefore the total=48000+64000=112000
Case 2:
M1xM2=(60x40x80)=192000 multiplications of (60x80 Matrix)
Then (M2xM1)xM3 = (60x80x20) =96000
Therefore the total=96000+192000=288000
Algorithm 2:
for(i=0; i<N; i++){
for(j=0; j<N; j++){
Statements;
}
Solution :
The algorithm 1 is a Single Loop Algorithm , therefore the time
complexity for it will be linear , which means that the running time of
the loop is directly proportional to N .
Solution
1. Let P(n): 13 + 23 + 33 + ··· + n3 = n2(n + 1)2.
= [12(1 + 1)2]
= RHS of P(1).
So P(1) is true.
3. Assume that P(k) is true, for an arbitrary fixed natural number k.
= (k + 1)2(k2 + 4k + 4)
= (k + 1)2(k + 2)2
= (k + 1)2(k + 1 + 1)2
Reference
1. Gamble.G. Induction: Problems with Solutions. Retrieved from
https://sites.ualberta.ca/~smartynk/Resources/CMPUT%20272/i
nductionprobs.pdf
2. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
Question 20: Mathematical Induction
Prove Bernouilli’s Inequality which states:
If x ≥ −1 then (1 + x)n ≥ 1 + nx for all natural numbers n.
Solution
1. Let P(n) = (1 + x)n ≥ 1 + nx, if x ≥ −1.
2. Basis Step: LHS of P(1) = (1 + x)1
=1+x
= 1+1x
= RHS of P(1).
So P(1) is true.
3. Assume that P(k) is true, for an arbitrary fixed natural number k.
Inductive Hypothesis: (1 + x)k ≥ 1 + kx, if x ≥ −1
4. Inductive Step: Deduce P(k + 1):
LHS of P(k + 1) = (1 + x)k+1
= [(1 + x)k] (1 + x)
= (LHS of P(k))(1 + x)
≥ (RHS of P(k))(1 + x), (by inductive assumption ...
1+
x ≥ 0 since x ≥ −1)
= (1 + kx)(1 + x)
=1+(k + 1)x + kx2
≥ 1+(k + 1)x, (since k > 0, x2 ≥ 0, so that kx2 ≥ 0)
= RHS of P(k + 1).
This completes the inductive step, so P(k + 1) is true, if P(k) is true.
5. Hence, by induction, we have shown that P(k + 1) follows from
P(k). Therefore if x ≥ −1 then (1 + x)n ≥ 1 + nx. P(n) is true for all
natural numbers n.
Reference
1. Gamble.G. Induction: Problems with Solutions. Retrieved from
https://sites.ualberta.ca/~smartynk/Resources/CMPUT%20272/i
nductionprobs.pdf
2. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
Chapter 5: Induction and Recursion
Question 21: Recursive Definition & Structural
Induction (Fibonacci number)
Suppose you want to go to a place that is 50 metres from you. At any
point, you can either move 1 metre or 2 metres towards it. In how
many unique ways can you reach the place?
Solution
To reach the destination (50m away from you) , we either move from 4t
o50m OR 48m to 50m for the last step. This means that the total number of
ways to reach 50m is the sum of number of ways to reach 48m and 49m.
Eg :
n=2, we can have solution moving 1m for two times (1,1) or simply
moving 2m in a single step (2).
n=3, the solution are (1,1,1) , (1,2) and (2,1).
n=4, the solution are (1,1,1,1) , (1,2,1) , (2,1,1) , (1,1,2) and (2,2).
Fibonacci series F(n) is a set of numbers with seed values 0 and 1, and the next
number is the sum of two preceding numbers.
Fibonacci series : 0,1,1,2,3,5,8,13,21,34,55,89,… f (n), n =1,2,3,... :
1,2,3,5,8,13,21,34,55,89,144,… Note that f (n) and Fibonacci series differ by 2
terms
The zeroth Fibonacci number is 0 while first Fibonacci number is 1 , if we want
to find f (50), we should take the 51st Fibonacci number.
Reference
1. Daniel I.A. Cohen. Introduction to Computer Theory. Wiley, 1986.
2. Thomas A. Sudkamp. Languages and Machines: An Introduction to
the Theory of Computer Science. 2e. Addison-Wesley, 1997.
3. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
Question 22: Recursive Definitions & Structural
Inductions
Show that for each integer n ≥ 2.
(Given that fn is the nth Fibonacci number)
Solution
Let P(n) be
Basic step n=2
0 =1–1
0 = 0 (QED)
Thus P(2) is true.
݇ ݇ ݇ ݇
݇ ݇ ݇ ݇
݇ ݇ ݇ ݇ ݇ ݇ ݇
݇ ݇ ݇ ݇ ݇
݇
݇
݇ ݇ ݇
݇
݇
We note that P(k+1) is true.
Conclusion
By the principle of mathematical induction,
for each integer n ≥ 2.
Reference
1. Daniel I.A. Cohen. Introduction to Computer Theory. Wiley, 1986.
2. Thomas A. Sudkamp. Languages and Machines: An Introduction to
the Theory of Computer Science. 2e. Addison-Wesley, 1997.
3. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.
Question 23: Recursive Algorithms
Imagine you are the lecturer of Computer Sciences and recently you
has done a quiz for 6 of your students , and the marks is already
decided , but the student challenged you to arrange their score of
marks in increasing order using merge sort graphical.
Compare 1 = (1, 2)
Compare 2 = (5, 3)
Compare 3 = (5, 4)
Compare 4 = (5, 12)
Compare 5 = (6, 12)
Compare 6 = (7, 12)
Compare 7 = (8,12)
Compare 8 = (12,20)
Total = 8 Comparison
Reference
1. Daniel I.A. Cohen. Introduction to Computer Theory. Wiley, 1986.
2. Thomas A. Sudkamp. Languages and Machines: An Introduction to
the Theory of Computer Science. 2e. Addison-Wesley, 1997.
3. Rosen, Kenneth H. (2019). Discrete mathematics and its
applications. [Eighth edition]. Washington, DC: McGraw-Hill
Education.