1 Section 2.3 Properties of Functions Let ƒ : A  B be a function. There are three properties that ƒ might possess. Injective (also called one-to-one):

Slides:



Advertisements
Similar presentations
1.6 Functions. Chapter 1, section 6 Functions notation: f: A B x in A, y in B, f(x) = y. concepts: –domain of f, –codomain of f, –range of f, –f maps.
Advertisements

Functions.
COUNTING AND PROBABILITY
The Integers and Division. Outline Division: Factors, multiples Exercise 2.3 Primes: The Fundamental Theorem of Arithmetic. The Division Algorithm Greatest.
1 Chapter Equivalence, Order, and Inductive Proof.
1 Chapter Facts about Functions. 2 Section 2.1 Functions: Definitions and Examples A function ƒ from A to B associates each element of A with exactly.
1 The RSA Algorithm Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
1.  The set N = {1,2,3,4,……..} is known as natural numbers or the set of positive integers  The natural numbers are used mainly for :  counting  ordering.
Tirgul 10 Rehearsal about Universal Hashing Solving two problems from theoretical exercises: –T2 q. 1 –T3 q. 2.
11.Hash Tables Hsu, Lih-Hsing. Computer Theory Lab. Chapter 11P Directed-address tables Direct addressing is a simple technique that works well.
1 Functions Chapter 10 Formal Specification using Z.
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,
Hashing General idea: Get a large array
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,
Section 4.1 Finite Permutation Groups Permutation of a Set Let A be the set { 1, 2, …, n }. A permutation on A is a function f : A  A that is both one-to-one.
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.
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Divisibility October 8, Divisibility If a and b are integers and a  0, then the statement that a divides b means that there is an integer c such.
Integers Number Theory = Properties of Integers
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
Section 2.2: Affine Ciphers; More Modular Arithmetic Practice HW (not to hand in) From Barr Textbook p. 80 # 2a, 3e, 3f, 4, 5a, 7, 8 9, 10 (Use affinecipherbreaker.
1 Section 10.1 What Is an Algebra? To most people the word algebra means high school algebra. But there are many kinds of algebra. An algebra consists.
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
Data Structures and Algorithm Analysis Hashing Lecturer: Jing Liu Homepage:
Prelude to Public-Key Cryptography Rocky K. C. Chang, February
D ESIGN & A NALYSIS OF A LGORITHM 02 – H ASHING (C ONTD.) Informatics Department Parahyangan Catholic University.
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.
1 Chapter Facts about Functions. 2 Section 2.3 Properties of Functions Let ƒ : A → B be a function. There are three properties that ƒ might possess.
1 Introduction to Abstract Mathematics Chapter 3: Elementary Number Theory and Methods of Proofs Instructor: Hayk Melikya Direct.
David Luebke 1 10/25/2015 CS 332: Algorithms Skip Lists Hash Tables.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Math 3121 Abstract Algebra I Lecture 9 Finish Section 10 Section 11.
FUNCTIONS.
MSU/CSE 260 Fall Functions Read Section 1.8.
1 Section 2.1 Functions: Definitions and Examples A function ƒ from A to B associates each element of A with exactly one element of B. Write ƒ : A  B.
Functions1 Elementary Discrete Mathematics Jim Skon.
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
MAT 3749 Introduction to Analysis Section 1.3 Part I Countable Sets
Chapter 9 Functions Let A and B be nonempty sets. A function f from A to B, written f: A  B is a relation from A to B with the property that every element.
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.
Section 2.2: Affine Ciphers; More Modular Arithmetic Shift ciphers use an additive key. To increase security, we can add a multiplicative parameter. –For.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
© 2001 by Charles E. Leiserson Introduction to AlgorithmsDay 12 L8.1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 8 Prof. Charles E. Leiserson.
Math 3121 Abstract Algebra I Lecture 5 Finish Sections 6 + Review: Cyclic Groups, Review.
Network and Computer Security (CS 475) Modular Arithmetic
October 5, 2005Copyright © by Erik D. Demaine and Charles E. LeisersonL7.1 Prof. Charles E. Leiserson L ECTURE 8 Hashing II Universal hashing Universality.
Discrete Structures Li Tak Sing ( 李德成 ) Lectures
1 Section Congruences In short, a congruence relation is an equivalence relation on the carrier of an algebra such that the operations of the algebra.
MA/CSSE 473 Day 08 Extended Euclid's Algorithm Modular Division Fermat's little theorem.
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.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.3, 7.4 and 7.5.
1 Section 4.2 Equivalence Relations A binary relation is an equivalence relation if it has the three properties reflexive, symmetric, and transitive (RST).
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.
Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang.
 If f is a one-to-one function with domain D and range R, then the inverse function of f, denoted f -1, is the function with domain R and range D defined.
CMSC250 S ECTIONS 0303 & 0304 M IDTERM R EVIEW Sri Kankanahalli Discussion 10: 9 March 2016 Office Hrs: Mon. and Wed. 4-6PM AVW 1112.
Introduction to Cryptography Hyunsung Kim, PhD University of Malawi, Chancellor College Kyungil University February, 2016.
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.
FUNCTIONS.
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division Fermat's little theorem intro.
Functions Goals Introduce the concept of function
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
Design & Analysis of Algorithm Hashing (Contd.)
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
CS201: Data Structures and Discrete Mathematics I
Yet another important mathematical concept
Copyright © Cengage Learning. All rights reserved.
Lecture 43 Section 10.1 Wed, Apr 6, 2005
Presentation transcript:

1 Section 2.3 Properties of Functions Let ƒ : A  B be a function. There are three properties that ƒ might possess. Injective (also called one-to-one): Distinct elements in A map to distinct elements in B. In other words, x ≠ y implies ƒ(x) ≠ ƒ(y) or, equivalently, ƒ(x) = ƒ(y) implies x = y. Example. Let ƒ : N 8  N be defined by ƒ(x) = 2x mod 8. ƒ is not injective. e.g., ƒ(0) = ƒ(4). Quiz (1 minute). Let ƒ : Z  N be defined by ƒ(x) = x 2. Is ƒ injective? Answer. No. e.g., ƒ(2) = ƒ(–2). Quiz (1 minute). Are any of the three functions injective? log 2, floor, ceiling. Answer. log 2 is injective, but floor and ceiling are not. Surjective (also called onto): The range is the codomain. In other words, each b  B has the form b = ƒ(a) for some a  A. Example. ƒ : Z  N defined by ƒ(x) = x 2 is not surjective. E.g., 2 is not a square. Example. ƒ : Z  N defined by ƒ(x) = | x | is surjective but not injective. Bijective (also called one-to-one and onto): Both injective and surjective. Example. Let ƒ : N  {a}* by ƒ(n) = a n. Then ƒ is a bijection. Example. The function ƒ : (0, 1)  (2, 5) defined by ƒ(x) = 3x + 2 is a bijection. Proof: If ƒ(x) = ƒ(y), then 3x + 2 = 3y + 2, which implies that x = y. So ƒ is injective. Let y  (2, 5). Does y = ƒ(x) = 3x + 2 for some x  (0, 1)? Solve the equation for x to get x = (y – 2)/3. Since y  (2, 5), we have y – 2  (0, 3). So x = (y – 2)/3  (0, 1). Thus ƒ(x) = y. So ƒ is surjective. Thus ƒ is bijective. Quiz (2 minutes). Let ƒ : R  R by ƒ(x) = x 3. Is ƒ bijective?

2 Inverses: If ƒ : A  B is a bijection, then there is an inverse function g : B  A defined by g(b) = a iff ƒ(a) = b. The inverse of ƒ is denoted by ƒ –1. Example. We have observed that the function ƒ : (0, 1)  (2, 5) defined by ƒ(x) = 3x + 2 is a bijection. So ƒ –1 : (2, 5)  (0, 1) is defined by ƒ –1 (x) = (x– 2)/3. Example. ƒ : N 5  N 5 defined by ƒ(x) = (4x + 1) mod 5 is a bijection (check each value). So it has an inverse. To see that it is a bijection (without listing the values) and to find a formula for the inverse, we can apply the following theorem. Theorem (mod and inverses) Let n > 1 and ƒ : N n  N n be defined by ƒ(x) = (ax + b) mod n. Then ƒ is bijective iff gcd(a, n) = 1. If so, then ƒ –1 (x) = (kx + c) mod n where ƒ(c) = 0 and 1 = ak + nm. Example. Let ƒ : N 5  N 5 be defined by ƒ(x) = (4x + 1) mod 5. Since gcd(4, 5) = 1, the theorem says that ƒ is a bijection. We test values to find c such that ƒ(c) = 0. e.g., ƒ(1) = 0. We can use Euclid’s algorithm to verify that 1 = gcd(4, 5) and then work backwards through the equations to find that 1 = 4(–1) + 5(1). So k = –1. Thus ƒ –1 (x) = (–x + 1) mod 5. (Check it out). Quiz (3 minutes). Let ƒ : N 13  N 13 be defined by ƒ(x) = (7x + 5) mod 13. Find ƒ –1 if it exists. Answer. gcd(7, 13) = 1. So ƒ is a bijection. ƒ(3) = 0 and 1 = 7(2) + 13(–1). So we can write ƒ –1 (x) = (2x + 3) mod 13.

3 Pigeon Hole Principle If m things are put into n places and m > n, then one place has two or more things. Another way to say this is that if A and B are finite sets with | A | > | B |, then there are no injections from A to B. Example. The function ƒ : N 7  N 6 defined by ƒ(x) = x mod 6 has ƒ(0) = ƒ(6). Example. In Mexico City there are two people with the same number of hairs on their heads. Everyone has less than 10 million hairs on their head and the population of Mexico City is more than 10 million. So the pigeon hole principle applies. Example. If 11 numbers are chosen from S = {1, 2, 3, …, 19, 20}, then for two of the numbers chosen one divides the other. Proof: Each natural number x ≥ 1 has a factorization x = 2 k m for some k ≥ 0 where m is odd. So the numbers in S can be written in this form: 1 = 2 0 ·1, 2 = 2 1 ·1, 3 = 2 0 ·3, 4 = 2 2 ·1, 5 = 2 0 ·5, …, 12 = 2 2 ·3, …, 19 = 2 0 ·19, 20 = 2 2 ·5. Notice that the values of m are in the set {1, 3, 5, 7, 9, 11, 13, 15, 17, 19}, which has 10 elements. So by the pigeon hole principle two of the 11 chosen numbers, say x and y, must share the same m. i.e., x = 2 k m and y = 2 j m for k ≠ j. So either x | y or y | x. QED. Quiz (2 minutes). Find 10 numbers in S that don’t divide each other. An answer: 6, 7, 8, 9, 11, 13, 15, 17, 19, 20. Ciphers and the mod function (some cryptology) Let the letters from a to z be represented by 0, 1, …, 25, respectively. Now any bijection ƒ : N 26  N 26 can act as a cipher and it’s inverse ƒ –1 can act as a decipher.

4 Example (additive cipher). ƒ(x) = (x + 2) mod 26 and ƒ –1 (x) = (x + 24) mod 26. Example (multiplicative cipher). ƒ(x) = 3x mod 26 and ƒ –1 (x) = 9x mod 26. Example (affine cipher). ƒ(x) = (5x + 1) mod 26 and ƒ –1 (x) = (–5x +5) mod 26. Some ciphers keep one or more letters fixed. For example, the cipher ƒ(x) = 3x mod 26 has ƒ(0) = 0, so it sends the letter a to itself. The following theorem can be used to construct ciphers with no fixed letters. Mod and Fixed Points Let n > 0 and let ƒ : N n  N n be defined by ƒ(x) = (ax + b) mod n. Then ƒ has no fixed points iff gcd(a – 1, n) does not divide b. Example. Both the additive and affine ciphers in the preceding examples have no fixed points. Hash Functions The goal is to use a key of some kind to look up information in a table, but without searching. A hash function maps a set S of keys into a finite set N n of table indexes. The table is called a hash table. Collisions occur if the function is not injective. If there are no collisions, then any key in S is mapped to the index where the information is stored without any searching. Example. Let S be the students in a class and let h : S  N 366 be defined by letting h(x) be the birthday of x. If two people have the same birthday, then a collision occurs.

5 Resolving Collisions by Linear Probing If a collision occurs at index k, then some key is placed in location k and the other colliding keys must be located elsewhere. Linear probing is a technique to search (probe) for an open place in the table by looking linearly at the following places, where g is a fixed gap: (k + g) mod n, (k + 2g) mod n, …, (k + (n – 1)g) mod n. Example. Let S = {jan, feb, mar, apr, may, jun} and let h : S  N 6 be defined by h(xyz) = p(x) mod 6, where p(x) is the position of x in the alphabet (p(a) = 1, …, p(z) = 26). We’ll place the keys from S into a hash table by first placing jan, then feb, and so on. h(jan) = p(j) mod 6 = 10 mod 6 = 4. So place jan in position 4 of the table. Continue the process to get h(feb) = 0, h(mar) = 1, h(apr) = 1 (collision with mar), h(may) = 1 (collision with mar and apr), and h(jun) = 4 (collision with jan). The table shows the result of resolving collisions by linear probing with a gap of 1. Quiz (2 minutes). Resolve collisions with gap = 2. Answer: feb, mar, jun, apr, jan, may. Quiz (2 minutes). Resolve collisions with gap = 3. Answer: feb, mar, blank, blank, jan, blank. (apr, may, and jun are not placed). Property: If n is the table size and g is a gap, then gcd(g, n) = 1 implies that all indexes are probed with gap g. So we were lucky to fill the table when the gap was 2. If the table size is a prime number p, then any gap other than p will insure that all keys are entered in the table. 0 feb 1 mar 2 apr 3 may 4 jan 5 jun