0% found this document useful (0 votes)
87 views52 pages

Assignment 1 Final

This document contains information about an assignment for a discrete structures course at the School of Computer Sciences. It lists the course code, semester, assignment details, and names of the lecturer and students in Group B2 who are completing the assignment. The assignment contains 8 questions related to topics in discrete mathematics including sets, functions, sequences, and cardinality. It provides the questions, solutions, and references for each question.

Uploaded by

Mirza Malaya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
87 views52 pages

Assignment 1 Final

This document contains information about an assignment for a discrete structures course at the School of Computer Sciences. It lists the course code, semester, assignment details, and names of the lecturer and students in Group B2 who are completing the assignment. The assignment contains 8 questions related to topics in discrete mathematics including sets, functions, sequences, and cardinality. It provides the questions, solutions, and references for each question.

Uploaded by

Mirza Malaya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 52

CPT112 – DISCRETE STUCTURES

SCHOOL OF COMPUTER SCIENCES

SEMESTER 2020/2021

ASSIGNMENT 1: GROUP ASSESMENT

LECTURER’S NAME: DR. NUR INTAN RAIHANA BINTI RUHAIYEM

GROUP: GROUP B2

NAMA NOMBOR MATRIKS


NG WAN ZHEN 153195
MUHAMMAD MIRZA BIN NORADZLI 153316
ONG JIA JIE 153818
Chapter 2: Basic Structures
Questions 1: Sets (Principle of Inclusion-Exclusion)
Question 1
As a USM Lecturer , you are given a task to separate your
class students into a few groups consist of 2 students in a
group with different genders , by using Cartesian Product ,
show the all possibility combination (Choose) of the matchup
in the groups using Cartesian Product

(Note : The order of the students matchup is not important and


neglected)

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

and n(N - M) = n(N) - n(M ∩ N)


= 83-23
=60

Therefore, Number of people speaking English only = 135


Number of people speaking Mandarin only = 60

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.

A = {21, 22, 23, 24, 25}


B = {15, 17, 19, 21,23}
C = {17, 19,21,23,25, 28}

The task is to find the differences of the set (Jersey Numbers)


between the three team, find the differences of set for:
a)A-B
b)B-C
c)C-A

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 ④

Note that ④  ③  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

Substitute f ( x)  mx  n into ①, we get


f 3a   3 f b   f  f a  b 
3am  n  3mb  n   f (a  b)m  n 
3am  3bm  4n  (a  b)m 2  mn  n
3am  3bm  3n  am 2  bm 2  mn ⑤

Compare both sides,

m 2  3m
m 2  3m  0
mm  3  0
m  0, m  3

When m  0 , from ⑤,
3a0   3b0   3n  a0   b0   0 n
2 2

n0

Thus f ( x)  0 for all x , but this contradicts as f (1)  2019 , so it is


false. m  3

Since we know f (1)  2019 , 3(1)  n  2019 and n  2016

 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

g(x) = √(x - 2020) and h(x) = x 2 + 2020

Find the composite function (g o h)(x).


Solution
(g o h)(x) = g(h(x))
= g(x 2 + 2020)
= g(x 2 + 2020)
= √(x 2 + 2020 - 2020)
=|x|
So
(g o h)(x) = | x |
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 7: Sequences & Summations
Kelvin bought a double story house with the price &200,000. The
value of the house increases 3% every year. Find and solve the
recurrence relation of the value of the house after n months. If Kelvin
wants to sell his house after 15 months, what is the price of the house?

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

Question 9: Cardinality Of Sets


If there is a one-to-one function from A to B, the cardinality of A is
less than or the same as the cardinality of B and we write |A| ≤ |B| and
If there is a one-to-one function from B to C, the cardinality of B is
less than or the same as the cardinality of C and we write |B| ≤ |C|.
The question is ,
Does |A| ≤ |C| true and exist? If yes , proof it

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|

From both of the definition , we can conclude that (using composition)


gf=A--->C , (gf)(a)=g(f(a))

Since gf is also one to one :


We can let (gf)(x) = (gf)(y) , which can be said that
f(x)=f(y) since g has a relation of one to one function,
Therefore , x=y since f is a one to one function.
In conclusion = gf is one to one

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=

Therefore, A[n] = A[4] for all positive integers n with n 5.


Reference
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.
Chapter 3: Algorithms
Question 13: Algorithms
Describe an algorithm that select jobs and sort for job sequence to
find maximum profit.
Input: Four Jobs with following deadlines and profits

JobID Deadline Profit


a 4 20
b 1 10
c 1 40
d 1 30

Output: Following is maximum profit sequence of jobs


c, a

Input: Five Jobs with following deadlines and profits


JobID Deadline Profit
a 2 100
b 1 19
c 2 27
d 1 25
e 3 15

Output: Following is maximum profit sequence of jobs


c, a, e

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

Determine the quotient with remainder using long division.

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

We always have the property x - 2 < x.

When x > 0, we also have the property <1

For convenience sake, we will choose k = 6 and use x >6.


ͻ
|f(x)| = |(x - 2) + |
ͻ
≤ |x - 2| + | |
ͻ
= (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

The question is which order of these matrices should be multiplied to


get the least number of multiplications of integers?

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

In conclusion , the Case 1 is more efficient .


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 18: Complexity of Algorithms
Time complexity of an algorithm is the total time required by the
program to run till the program is completed .The time complexity of
algorithms is most commonly expressed using the big O notation.
Given below 2 different algorithm that look identical but have a
different in terms of relation of N towards the running time . Explain
the differences, and stated the big O notation of the algorithm.
Solutions
Algorithm 1:
for(i=0; i<N; i++){
Statements;
}

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 .

The algorithm 2 is a Nested Loop Algorithm , therefore the time


complexity for it will be quadratic (NxN) , which means that the
running time of the two loops is proportional to the square of N.

Big O notation for


Algorithm 1 : O(N) (linear)
Algorithm 2 : O(N^2) (Quadratic)
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
Chapter 5: Induction and Recursion
Question 19: Mathematical Induction
Prove for any natural number n that

13 + 23 + 33 + ··· + n3 = n2(n + 1)2

Solution
1. Let P(n): 13 + 23 + 33 + ··· + n3 = n2(n + 1)2.

2. Basis Step: LHS of P(1) = 13 = 1

= [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.

Inductive Hypothesis: 13 + 23 + 33 + ··· + k3 = k2(k + 1)2

4. Inductive Step: Deduce P(k + 1).


LHS of P(k + 1) = 13 + 23 + 33 + ··· + k3 + (k + 1)3
= [13 + 23 + 33 + ··· + k3] + (k + 1)3

= k2(k + 1)2 + (k + 1)3 (by inductive assumption)

= (k + 1)2 [k2 + 4(k + 1)]

= (k + 1)2(k2 + 4k + 4)

= (k + 1)2(k + 2)2

= (k + 1)2(k + 1 + 1)2

= 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 the sum of the first n positive cubic integers is n2(n
+ 1)2. 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.
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.

Denote f (n) as the number of ways to reach n metres.

We can write it as f (n) = f (n −1) + f (n − 2) because for every events of


reaching n metres is obtained by moving 1 metre forward fromn−1metres OR
moving 2 metres forward from n − 2 metres.

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

Comes from Comes from n=2


n=3,
Add 2 as the last
Add 1 as the step

Thus, the number of ways of


reaching n metres forms
Fibonacci Series

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.

The first 51 Fibonacci numbers


n : F(n)=factorisation
0:0
1:1
2:1
3:2
4:3
5:5
6 : 8 = 23
7 : 13
8 : 21 = 3 x 7
9 : 34 = 2 x 17
10 : 55 = 5 x 11
11 : 89
12 : 144 = 24 x 32
13 : 233
14 : 377 = 13 x 29
15 : 610 = 2 x 5 x 61
16 : 987 = 3 x 7 x 47
17 : 1597
18 : 2584 = 23 x 17 x 19
19 : 4181 = 37 x 113
20 : 6765 = 3 x 5 x 11 x 41
21 : 10946 = 2 x 13 x 421
22 : 17711 = 89 x 199
23 : 28657
24 : 46368 = 25 x 32 x 7 x 23
25 : 75025 = 52 x 3001
26 : 121393 = 233 x 521
27 : 196418 = 2 x 17 x 53 x 109
28 : 317811 = 3 x 13 x 29 x 281
29 : 514229
30 : 832040 = 23 x 5 x 11 x 31 x 61
31 : 1346269 = 557 x 2417
32 : 2178309 = 3 x 7 x 47 x 2207
33 : 3524578 = 2 x 89 x 19801
34 : 5702887 = 1597 x 3571
35 : 9227465 = 5 x 13 x 141961
36 : 14930352 = 24 x 33 x 17 x 19 x 107
37 : 24157817 = 73 x 149 x 2221
38 : 39088169 = 37 x 113 x 9349
39 : 63245986 = 2 x 233 x 135721
40 : 102334155 = 3 x 5 x 7 x 11 x 41 x 2161
41 : 165580141 = 2789 x 59369
42 : 267914296 = 23 x 13 x 29 x 211 x 421
43 : 433494437
44 : 701408733 = 3 x 43 x 89 x 199 x 307
45 : 1134903170 = 2 x 5 x 17 x 61 x 109441
46 : 1836311903 = 139 x 461 x 28657
47 : 2971215073
48 : 4807526976 = 26 x 32 x 7 x 23 x 47 x 1103
49 : 7778742049 = 13 x 97 x 6168709
50 : 12586269025 = 52 x 11 x 101 x 151 x 3001
51 : 20365011074 = 2 x 1597 x 6376021

Answer= 20365011074 ways

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.

Induction step We assume that P(k) is true


We need to prove that P(k+1) is also true.
݇
݇ ݇ ݇

Let us consider the following:

݇ ݇ ݇ ݇

݇ ݇ ݇ ݇
݇ ݇ ݇ ݇ ݇ ݇ ݇
݇ ݇ ݇ ݇ ݇
݇

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

The marks of your 6 students = M


M={23,34,56,48,12,78)
Solution
6,5,12,10,9,1
/ \
6,5,12 10,9,1
/ \ / \
6 5,12 10 9,1
/ /\ / / \
6 5 12 10 9 1
\ \ / / \ /
6 5 12 10 1 9
\ / \ /
5,6,12 1,9,10
\ /
1,5,6,9,10,12
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 24: Recursive Algorithms
As a lecturer , you had just finished to merge sort the list number of
(1, 5, 6, 7, 8; 2, 3, 4, 12, 20) , But one of your student asked you about
how many comparisons are needed in the merge sorting process.

list number = (1, 5, 6, 7, 8; 2, 3, 4, 12, 20)


Solution
Divide into two list :
List 1 : 1, 5, 6, 7, 8
List 2 : 2, 3, 4, 12, 20

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.

You might also like