Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Function, Recursion and Analysis - Discrete Mathematics - Lecture Slides, Slides of Discrete Mathematics

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

2012/2013

Uploaded on 04/23/2013

sarangapani
sarangapani 🇮🇳

4.5

(10)

63 documents

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
CSE20Lecture11
Function,Recursion&Analysis
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Function, Recursion and Analysis - Discrete Mathematics - Lecture Slides and more Slides Discrete Mathematics in PDF only on Docsity!

CSE

Lecture

Function,

Recursion

Analysis

Docsity.com

Motivation

•^

Verification

-^

Complexity

of

the

execution

Input x

Output y

y= Function (x)

Recursion

Docsity.com

I.

Definition

•^

A

function

f:

A

B

maps

elements

in

domain

A

to

codomain

B

such

that

for

each

a

ϵ

A,

f(a)

is

exact

one

element

in

B.

•^

f:

A

B

A:

Domain B:

Codomain f(A):

range

or

image

of

function

f(A)

B

Docsity.com

Examples

(2)

f(x) (1)

f(x)=x

2 ,

x

(3)

f(x)

NOT

a

function

x

f(x)

f(x)

x Docsity.com

Function:

iClicker

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

Formulation

of

Recursive

Functions

Overview of Recursive Functions

Examples^ 1.

Fibonacci Sequence

The Tower of Hanoi

Merge Sort

Docsity.com

Recursive

Functions:

iClicker

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:

Problem

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

Fibonacci

Sequence:

iClicker

The

following

is

Fibonacci

sequence:

•^

A.

•^

B.

•^

C.

•^

D.

•^

E.

None

of

the

above

Docsity.com

Fibonacci

Sequence:

Recursion

Function

Fibonacci(n)

If

n<

return

n

Else

return(Fibonacci(n

‐1)+Fibonacci(n

Index:

F(i):

Docsity.com

Fibonacci

sequence:

Golden

Ratio

-^

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

Fibonacci

Sequence

and

the

golden

ratio

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

Tower

of

Hanoi:

Problem

Hanoi

(4,

1,

3):

Move

4

disks

from

pole

1

to

pole

Docsity.com

Tower

of

Hanoi:

Function

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