1 Relations and Functions Chapter 5 1 to many 1 to 1 many to many.

Slides:



Advertisements
Similar presentations
Chapter 5 Relations and Functions
Advertisements

COUNTING AND PROBABILITY
Transitive Closure Theorem 1. Let R be a relation on a set A. Then R  is the transitive closure of R. the reachability relation R * of a relation R on.
Functions Section 2.3 of Rosen Fall 2008
Discrete Structures Chapter 5 Pigeonhole Principle Nurul Amelina Nasharuddin Multimedia Department.
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Discrete Mathematics Lecture 7 Alexander Bukharovich New York University.
Lecture 3 Set Operations & Set Functions. Recap Set: unordered collection of objects Equal sets have the same elements Subset: elements in A are also.
Functions f( ) = A B Lecture 15: Nov 4.
Discrete Math for CS Chapter 5: Functions. Discrete Math for CS New Relation Operations: Given R, a relation on A x B, we define the inverse relation,
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
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,
RMIT University; Taylor's College
Functions.
Chapter 7 Functions Dr. Curry Guinn. Outline of Today Section 7.1: Functions Defined on General Sets Section 7.2: One-to-One and Onto Section 7.3: The.
Functions, Sequences, and Sums
Functions A B f( ) =. This Lecture We will define a function formally, and then in the next lecture we will use this concept in counting. We will also.
FUNCTION Discrete Mathematics Asst. Prof. Dr. Choopan Rattanapoka.
February 12, 2015Applied Discrete Mathematics Week 2: Functions and Sequences 1Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3,
Chapter 3 Functions Functions provide a means of expressing relationships between variables, which can be numbers or non-numerical objects.
Functions. Copyright © Peter Cappello2 Definition Let D and C be nonempty sets. A function f from D to C, for each element d  D, assigns exactly 1 element.
ICS 253: Discrete Structures I
Week 7 - Friday.  What did we talk about last time?  Set disproofs  Russell’s paradox  Function basics.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
FUNCTIONS.
Chap. 5 Relations and Functions. Cartesian Product For sets A, B the Cartesian product, or cross product, of A and B is denoted by A ╳ B and equals {(a,
Functions Section 2.3 of Rosen Spring 2012 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions: Use Piazza.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1 Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 1 The Foundations: Logic, Sets,
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
321 Section, Week 3 Natalie Linnell. Functions A function from A to B is an assignment of exactly one element of B to each element of A. We write f(a)
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Example Prove that: “IF 3n + 2 is odd, then n is odd” Proof by Contradiction: -p = 3n + 2 is odd, q = n is odd. -Assume that ~(p  q) is true OR -(p 
Basic Structures: Functions Muhammad Arief download dari
Chapter 5 – Relations and Functions. 5.1Cartesian Products and Relations Definition 5.1: For sets A, B  U, the Cartesian product, or cross product, of.
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
Discrete Mathematics R. Johnsonbaugh
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
Sets. Definitions (I) Collection of elements such that: There are no duplicates There is no order Special sets Universe (U or E): all elements under consideration.
Counting Discrete Mathematics. Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter passwords are there?”
Chapter Four Functions. Section 4.1 A function from a set D to set R (f: D  R) is a relation from D to R such that each x in D is related to one and.
Discrete Structures Li Tak Sing ( 李德成 ) Lectures
Basic Structures: Sets, Functions, Sequences, and Sums.
1 Discrete and Combinatorial Mathematics R. P. Grimaldi, 5 th edition, 2004 Chapter 5 Relations and Functions.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
CSC102 - Discrete Structures Functions
1 Functions CS 202 Epp section ??? Aaron Bloomfield.
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.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang.
Pigeonhole Principle. If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons A function from one finite.
Main Menu Main Menu (Click on the topics below) Pigeonhole Principle Example Generalized Pigeonhole Principle Example Proof of Pigeonhole Principle Click.
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 
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
ICS 253: Discrete Structures I
Relations, Functions, and Matrices
Chapter 2 Sets and Functions.
Relation and function.
Functions Section 2.3.
Lecture 7 Functions.
CSE15 Discrete Mathematics 02/27/17
CS100: Discrete structures
ICS 253: Discrete Structures I
Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2.
Functions Section 2.3.
Presentation transcript:

1 Relations and Functions Chapter 5 1 to many 1 to 1 many to many

2 5.1 Cartesian Products and Relations the elements of A B are ordered pairs |A B|=|A| |B|=|B A|

3 5.1 Cartesian Products and Relations Ex. 5.3 The sample space by rolling a die first then flipping a coin Tree structure ,H 1,T 2,H 2,T 3,H 3,T 4,H 4,T 5,H 5,T 6,H 6,T ={1,2,3,4,5,6} {H,T}

4 5.1 Cartesian Products and Relations Trees are convenient tools for enumeration. Ex. 5.4 At the Wimbledon Tennis Championships, women play at most 3 sets in a match. The winner is the first to win two sets. In how many ways can a match be won? N E N E N E N E N E Therefore, 6 ways.

5 5.1 Cartesian Products and Relations In general, for finite sets A,B with |A|=m and |B|=n, there are 2 mn relations from A to B, including the empty relation as well as the relation A B itself. Ex. 5.7 A=Z +, a binary relation, R, on A, {(x,y)|x<y} (1,2), (7,11) is in R, but (2,2), (3,2) is not in R or 1R2, 7R11 (infix notation)

6 5.1 Cartesian Products and Relations

7 5.2 Functions: Plain and One-to-One Def. 5.3 For nonempty sets, A,B, a function, or mapping, f from A to B, denoted f:A B, is a relation from A to B in which every element of A appears exactly once as the first component of an ordered pair in the relation. set A set B not allowed

8 5.2 Functions: Plain and One-to-One Def 5.4 Domain, Codomain, Range a b f(a)=b domaincodomain range AB

9 5.2 Functions: Plain and One-to-One

Functions: Plain and One-to-One If |A|=m, |B|=n, then the number of possible functions from A to B is n m. Def 5.5 A function f:A B is called one-to-one, or injective, if each element of B appears at most once as the image of an element of A.

Functions: Plain and One-to-One If |A|=m, |B|=n, and, then the number of one-to-one functions from A to B is P(n,m)=n!/(n-m)!.

Functions: Plain and One-to-One 123 a b

Onto Functions: Stirling Number of the Second Kind Ex 5.19 f:R R defined by f(x)=x 3 is onto. But f(x)=x 2 is not. Ex f:Z Z where f(x)=3x+1 is not onto. g:Q Q where g(x)=3x+1 is onto. h:R R where h(x)=3x+1 is onto. If A,B are finite sets, then for any onto function f:A B to possibly exist we must have |A| |B|. But how many onto functions are there?

Onto Functions: Stirling Number of the Second Kind

Onto Functions: Stirling Number of the Second Kind Ex For A={w,x,y,z} and B={1,2,3}, there are 3 4 functions from A to B. Among all functions: (1) {1} is not mapped: 2 4 functions from A to {2,3} (2) {2} is not mapped: 2 4 functions from A to {1,3} (1) {3} is not mapped: 2 4 functions from A to {1,2} But the functions A to {1} or {2} or {3} are all counted twice. Therefore, number of onto functions from A to B is (What about m=1 or m=2?)

Onto Functions: Stirling Number of the Second Kind General formula

Onto Functions: Stirling Number of the Second Kind Examples at the beginning of this chapter (P217) (1) seven contracts to be awarded to 4 companies such that every company is involved? (2) How many seven-symbol quaternary (0,1,2,3) sequences have at least one occurrence of each of the symbols 0,1,2, and 3? (3) How many 7 by 4 zero-one matrices have exactly one 1 in each row and at least one 1 in each column?

Onto Functions: Stirling Number of the Second Kind Examples at the beginning of this chapter (P217) (4) Seven unrelated people enter the lobby of a building which has four additional floors, and they all get on an elevator. What is the probability that the elevator must stop at every floor in order to let passengers off? 8400/4 7 =8400/16384>0.5 (5) For positive integers m,n with m<n, prove that (6) For every positive integer n, verify that

Onto Functions: Stirling Number of the Second Kind Ex jobs to be distributed to 4 people, each one gets at least one job and job 1 is assigned to person 1. Ans: case 1: person 1 gets only job 1 onto functions from 6 elements to 3 elements (persons) case 2: person1 gets more than one job onto functions from 6 elements to 4 elements (persons)

Onto Functions: Stirling Number of the Second Kind The number of ways to distribute m distinct objects into n different containers with no container left empty is If the containers are identical: S(m,n): Stirling number of the second kind n!S(m,n) onto functions Ex distribute m distinct objects into n identical containers with empty containers allowed

Onto Functions: Stirling Number of the Second Kind Proof: n identical containers S(m+1,n) a m+1 is alone in one containera m+1 is not alone in one container S(m,n-1) Distribute other n objects first into n containers. Then a m+1 can be put into one of them. nS(m,n)

Onto Functions: Stirling Number of the Second Kind Ex How many ways to factorize into at least two factors (greater than 1) where order is not relevant? Ans: There are at most 6 factors. Therefore, the answer is S(6,2)+ S(6,3)+S(6,4)+S(6,5)+S(6,6)=202 Ex. Prove that for all Proof: m n : ways to distribute n distinct objects into m distinct containers i!S(n,i): ways to distribute n distinct objects into i distinct containers with no empty containers

Special Functions

Special Functions

Special Functions a b c d abcdabcd entries Therefore,

Special Functions

Special Functions identity

Special Functions a 1 a 2 a 3... a n a1a2a3...ana1a2a3...an n 2 entries, each has n choices

Special Functions n entries a 1 a 2 a 3... a n a1a2a3...ana1a2a3...an

Special Functions If a 1 is the identity a 1 a 2 a 3... a n a 2 a 3... a n a1a2a3...ana1a2a3...an a1a2a3...ana1a2a3...an

Special Functions If a 1 is the identity a 1 a 2 a 3... a n a 2 a 3... a n a1a2a3...ana1a2a3...an a1a2a3...ana1a2a3...an n-1 entries

Special Functions

The Pigeonhole Principle The Pigeonhole Principle: If m pigeons occupy n pigeonholes and m>n, then at least one pigeonhole has two or more pigeons roosting in it. For example, of 3 people, two are of the same sex. Of 13 people, two are born in the same month. Ex A tape contains 500,000 words of four or fewer lower lowercase letters. Can it be that they are all different?

The Pigeonhole Principle

The Pigeonhole Principle Ex Any subset of size six from the set S={1,2,3,...,9} must contain two elements whose sum is 10. pigeonholes: {1,9},{2,8},{3,7},{4,6},(5} pigeons: six of them Therefore, at two elements must be from the same subset. Ex Triangle ACE is equilateral with AC=1. If five points are selected from the interior of the triangle, there are at least two whose distance apart is less than 1/2. region 1region 2region 3region 44 pigeonholes 5 pigeons

The Pigeonhole Principle Ex Let S be a set of six positive integers whose maximum is at most 14. Show that the sums of the elements in all the nonempty subsets of S cannot all be distinct. For any nonempty subset A of S, the sum of the elements in A, denoted SA, satifies, and there are =63 nonempty subsets of S. (two many pigeonholes!) Consider the subset of less than 6 elements. pigeonholes= =60 pigeons= =62

The Pigeonhole Principle

The Pigeonhole Principle Ex days to play at most 40 sets of tennis and at least 1 play per day. Prove there is a consecutive span of days during which exactly 15 sets are played.

Function Composition and Inverse Functions Def 5.15 If f:A B, then f is said to be bijective, or to be a one-to-one correspondence, if f is both one-to-one and onto wxyzwxyz A B must be |A|=|B| (if ) but could be Ex. 5.50

Function Composition and Inverse Functions

Function Composition and Inverse Functions Ex A B C abcabc wxyzwxyz f g

Function Composition and Inverse Functions A BC f g

Function Composition and Inverse Functions A BC f g D h gf hg h(gf) (hg)f

Function Composition and Inverse Functions AB f g

Function Composition and Inverse Functions

Function Composition and Inverse Functions

Function Composition and Inverse Functions

Computational Complexity problem algorithm 1 algorithm 2 algorithm k Which one is best? We need measures. time-complexity or space-complexity a function f(n) where n is the size of the input lower bounds, best cases, average cases, worst cases

Computational Complexity Big-Oh Form Name O(1) constant O(log 2 n) Logarithmic O(n) Linear O(nlog 2 n) nlog 2 n O(n 2 ) Quadratic O(n 3 ) Cubic O(n m ),m=0,1,2,3,... Polynomial O(c n ),c>1 Exponential O(n!) Factorial

Computational Complexity Order of Complexity problem size nlog 2 n n nlog 2 n n 2 2 n n! >10 89

51 Summaries (m objects, n containers) Objects Containers Some Number Ar Are Containers of Distinct Distinct May Be Empty Distributions Yes Yes Yes Yes Yes No Yes No Yes Yes No No No Yes Yes No Yes No Put one object in each container first.

52 Exercise. P252: 7,12 P258: 6,14,20,27 P256: 7,9,10,12 P272: 5,6,8,14 P277: 6,7,10,13,20 P305: 12,25, 27