1 CSE 20 Lecture 11 Function, Recursion & Analysis (Ch. 6 Shaum’s ) May 3, 2011.

Slides:



Advertisements
Similar presentations
Relations Functions Definition: Definition:
Advertisements

FUNCTIONS Section 3.1.
Recursive Definitions and Induction Proofs Rosen 3.4.
CSE115/ENGR160 Discrete Mathematics 02/16/12 Ming-Hsuan Yang UC Merced 1.
Recursion. Recursive Definitions In recursive definitions, we define a function, a predicate, a set, or a more complex structure over an infinite domain.
Revision Using Recursion1 Recursion. Revision Using Recursion2 Recall the Recursion Pattern Recursion: when a method calls itself Classic example--the.
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
RELATIONS AND FUNCTIONS
Fibonacci numbers Fibonacci numbers:Fibonacci numbers 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,... where each number is the sum of the preceding two. Recursive.
Function: Definition A function is a correspondence from a first set, called the domain, to a second set, called the range, such that each element in the.
RMIT University; Taylor's College
Functions.
Functions, Sequences, and Sums
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
Functions.
2.4 Functions and Graphs Objective: Understand functions.
9/8/ Relations and Functions Unit 3-3 Sec. 3.1.
Functions Domain and range The domain of a function f(x) is the set of all possible x values. (the input values) The range of a function f(x) is the set.
Discrete Mathematics Algorithms. Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are.
Chapter 3 Functions Functions provide a means of expressing relationships between variables, which can be numbers or non-numerical objects.
Relations and Functions
Functions and Their Properties Def: Function, Domain and Range A function from a set D to a set R is a rule that assigns to every element in D a unique.
1.2 Represent Functions as Rules and Tables EQ: How do I represent functions as rules and tables??
FUNCTIONS.
1 CSE 20 Lecture 11 Function, Recursion & Analysis CK Cheng UC San Diego.
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
Basic Structures: Functions Muhammad Arief download dari
CSE 2353 – October 1 st 2003 Functions. For Real Numbers F: R->R –f(x) = 7x + 5 –f(x) = sin(x)
Functions Definition: A relation ‘ f ’ from set X to set Y is a function if each element in set X is mapped to exactly one element in set Y
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
MT263F Discrete Structures Li Tak Sing ( 李德成 ) Lectures
Fundamentals of Algorithms MCS - 2 Lecture # 8. Growth of Functions.
Objectives 1. To determine if a relation is a function.
Functions Section 1.4. Relation The value of one variable is related to the value of a second variable A correspondence between two sets If x and y are.
1 CSE 20 Lecture 13: Analysis of Recursive Functions CK Cheng.
Math – What is a Function? 1. 2 input output function.
Relations and Functions Intermediate Algebra II Section 2.1.
Bell Ringer 10/30/ Objectives The student will be able to: 1. identify the domain and range of a relation. 2. show relations as sets and mappings.
A Different Solution  alternatively we can use the following algorithm: 1. if n == 0 done, otherwise I. print the string once II. print the string (n.
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Questions 4) What type of algorithmic problem-solving technique (greedy, divide-and-conquer, dynamic programming)
Review Functions. Function A function is a special type of relation in which each element of the domain is paired with exactly one element of the range.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
Section 2.3. Section Summary  Definition of a Function. o Domain, Cdomain o Image, Preimage  One-to-one (Injection), onto (Surjection), Bijection 
FUNCTIONS.
Functions Section 2.3.
Discrete Mathematics CS 2610
CSE15 Discrete Mathematics 02/15/17
Functions Learning Objectives To understand function notation
Functions & Graphing.
CSE322 Recursive and Recursively enumerable sets
4.8 Functions and Relations
2-1 Relations and Functions
Relations and Functions
Lecture 7 Functions.
CS100: Discrete structures
Objective 1A f(x) = 2x + 3 What is the Range of the function
Section 11.1 Sequences.
Dr. Fowler  CCM Functions.
Warm Up Given y = –x² – x + 2 and the x-value, find the y-value in each… 1. x = –3, y = ____ 2. x = 0, y = ____ 3. x = 1, y = ____ –4 – −3 2 –
Lesson 1-1 Linear Relations and Things related to linear functions
Relations and Functions
Ch 5 Functions Chapter 5: Functions
2.1: Represent Relations and Functions HW: p.76 (4-20 even, all)
Applied Discrete Mathematics Week 7: Computation
Unit 2 Lesson 1 Function Definitions.
Functions and Relations
Unit 1 Jeopardy Review!.
Relation (a set of ordered pairs)
I can determine whether a relation is a function
Presentation transcript:

1 CSE 20 Lecture 11 Function, Recursion & Analysis (Ch. 6 Shaum’s ) May 3, 2011

Motivation Complexity of the execution 2 Input x Output y y= Function (x) Recursion

OUTLINE DEFINITION FUNTION RECURSION: CASES ANALYSIS 3

4 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

5 Examples (2) f(x) (1) f(x)=x 2, x ∈ ℝ (3) f(x) NOT a function

6 (5) NOT a function Examples (4) Mapping from x to y When domain A is an integer set Z, we may denote f(x) as f x, ie. f 0, f 1, f 2.

7 Case of Recursion Fibonacci Sequence Index: Sequence:

8 Another Case of Recursion: Ackermann Function Ackermann Function: A(m,n), m, n ∈ N 1) m=0: A(0,n)=n+1 2) m≠0, n=0: A(m,0)=A(m-1,1) 3) m≠0, n≠0: A(m,n)=A(m-1, A(m,n-1)) Example: A(1,1)= A(0, A(1,0)) =A(0,2) A(2,0) =A(1,1)

9 Ackermann Function (0,0) (0,1) (0,2) (0,3) (0,4) (0,5) (0,6) (0,7) A(0,n)=n+1 (1,0) (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) A(1,n)=n+2 (2,0) (2,1) (2,2) (2,3) (2,4)(2,5) A(2,n)=2n+3 (3,0) (3,1) (3,2) A(3,n)= (4,0)(4,1)

10 Ackermann Function - Comparison Ackermann Function: grows faster than an exponential function Googol: Visible universe ≈ atoms

11 Fibonacci Sequence Fibonacci sequence: Start with a pair of rabbits. Every month each pair bears a pair, which becomes productive from the second month. Calculate the number of new pairs in month i, i≥0.

12 Analysis of Fibonacci Sequence Algorithm array n(i) (new born), a(i) (adult) Init n(0)=0, a(0)=1 For i=1, i=i+1 n(i)=a(i-1) a(i)=a(i-1)+n(i-1) Index: … a(i): … n(i): …

13 Fibonacci sequence: Golden Ratio Derivation: Let We have:

14 Fibonacci Sequence and the golden ratio