


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
These lecture slides are very helpful for the student of discrete mathematics. The major points in these exam paper are: Function, Recursion and Analysis, Complexity of Execution, Verification, Formulation of Recursive Functions, Induction, Counting, Verification, Analysis, Image of Function, Integer Set, Fibonacci Sequence
Typology: Slides
1 / 26
This page cannot be seen from the preview
Don't miss anything!
Docsity.com
Verification
-^
Complexity
of
the
execution
Input x
Output y
y= Function (x)
Recursion
Docsity.com
function
f:
maps
elements
in
domain
to
codomain
such
that
for
each
a
ϵ
f(a)
is
exact
one
element
in
f:
Domain B:
Codomain f(A):
range
or
image
of
function
f(A)
Docsity.com
(2)
f(x) (1)
f(x)=x
2 ,
x
(3)
f(x)
NOT
a
function
x
f(x)
f(x)
x Docsity.com
Let X={1,2,3,4}. Determine which ofthe following relation is a function A. f={(1,3), (2,4), (3,3)} B. g={(1,2), (3,4), (1,4), (2,3)} C. h={(1,4), (2,3), (3,2), (4,1)} D. w={(1,1), (2,2), (3,3), (4,4)} E. Two of the above.
Docsity.com
Overview of Recursive Functions
Examples^ 1.
Fibonacci Sequence
The Tower of Hanoi
Merge Sort
Docsity.com
A. We can convert a recursivefunction into a program with iterativeloops. B. Recursive function takes much lesslines of codes for some problems. C. Recursive function always runsslower due to its complexity. D. Two of the above E. None of the above.
Docsity.com
Fibonacci
sequence:
Start
with
a
pair
of
rabbits.
For
every
month,
each
pair
bears
a
new
pair,
which
becomes
productive
from
their
second
month.
Calculate
the
number
of
new
pairs
in
month
i,
i
Docsity.com
Docsity.com
Function
Fibonacci(n)
If
n<
return
n
Else
return(Fibonacci(n
‐1)+Fibonacci(n
Index:
F(i):
Docsity.com
-^
Derivation:
-^
Let
-^
We
have:
1
5 2
n X
→∞
=
(^1) −
=
n n
n^
f f
X
1 2
2 1
1
2
1
1
1
1
1
− −
− −
−
−
−
−
n n
n n
n
n
n
n n
f f
f f
f
f
f
f f n
X
X
X
X
1 1
=
Docsity.com
0
1
2
3
4
5
6
7
8
9
0
1
1
2
3
5
8
13
21
34
1
2
(^1) − fn fn
Docsity.com
Hanoi
(4,
1,
3):
Move
4
disks
from
pole
1
to
pole
Docsity.com
Setting:
n,
A=1,
B=
(move
n
disks
from
pole
to
pole
Output:
a
sequence
of
moves
(a,
b)
Function
Hanoi(n,
A,
B)
If
n=1,
return
(A,
B),
Else
{ C
<=
other
pole(not
A
nor
B)
return
Hanoi(n
‐1,
A,
C),
(A,
B),
Hanoi(n
‐1,
C,
B)
}
Docsity.com