Download presentation
Presentation is loading. Please wait.
Published byAdele Roberts Modified over 9 years ago
1
CSCI 115 Chapter 5 Functions
2
CSCI 115 §5.1 Functions
3
§5.1 – Functions Function –Relation such that for every domain element a, |f(a)| = 1 –Mappings, transformations –f(a) = {b} f(a) = b a = argument b = function value
4
§5.1 – Functions Types of functions –Everywhere defined –Onto –One to one (1–1) –1 – 1 Correspondence ED, Onto, 1–1 –Invertible Functions
5
§5.1 – Functions Theorem 5.1.1
6
§5.1 – Functions Theorem 5.1.2
7
§5.1 – Functions Theorem 5.1.4
8
§5.1 – Functions 1-1 functions and cryptography –Allows coding AND decoding –Substitution codes Table from Example 18 (p. 188)
9
CSCI 115 §5.2 Functions for Computer Science
10
§5.2 – Functions for Computer Science mod–n (or mod n ) Factorial Floor Ceiling Boolean Hashing Others
11
§5.2 – Functions for Computer Science Set –Collection of objects –Any element is unambiguously in the set or not –Characteristic function Fuzzy sets –Whether or not an element is in the set may be ‘fuzzy’ –The set of all rich people
12
§5.2 – Functions for Computer Science Fuzzy sets –Function f defined on a set having values in the interval [0, 1] If f(x) = 0, x is not in the set If f(x) = 1, x is in the set If 0 < f(x) < 1 then f(x) is the degree to which x is in the set –Degree of membership –Ordinary sets are special cases of fuzzy sets
13
§5.2 – Functions for Computer Science Fuzzy set operations –Theorem 5.2.1 (Finding other degrees of membership) Let A and B be subsets of the same universal set U. Then:
14
§5.2 – Functions for Computer Science Fuzzy Logic –Fuzzy predicates Values can be true, false, or somewhere in between –Schrodinger’s Cat –Quantum theory and computers –Applications Control theory –Elevator operation –ABS systems in cars Expert systems
15
CSCI 115 §5.3 Growth of Functions
16
§5.3 – Growth of Functions Algorithmic Analysis –Efficiency Number of steps (running time) –Comparison
17
§5.3 – Growth of Functions Definitions –Let f and g be functions whose domains are subsets of Z +. We say f is O(g) (read f is big-Oh of g) if constants c and k s.t. |f(n)| c |g(n)| n k. We say f and g have the same order if f is O(g) and g is O(f) We say f is lower order than g (or f grows more slowly than g) if f is O(g) but g is not O(f)
18
§5.3 – Growth of Functions Definition –We define a relation Θ (called big-theta) on functions whose domains are subsets of Z + as: f Θ g iff f and g have the same order. Theorem 5.3.1 –The relation Θ is an equivalence relation.
19
§5.3 – Growth of Functions Equivalence classes of Θ –Equivalence classes (called Θ–classes) consist of functions of the same order –One Θ–class is said to be lower than another if any of the functions in the first is lower than any in the second –Θ–classes provide the necessary information to do algorithmic analysis
20
§5.3 – Growth of Functions Image from page 203 of the text
21
CSCI 115 §5.4 Permutation Functions
22
§5.4 – Permutation Functions Permutation –1-1 correspondence from a set onto itself Theorem 5.4.1 –If A = {a 1, a 2, …, a n } with |A| = n, then n! permutations of A
23
§5.4 – Permutation Functions Cycle of length r –If p(a 1 ) = a 2, p(a 2 ) = a 3, …, p(a r-1 ) = a r and p(a r ) = a 1, this is called a cycle of length r, and is denoted (a 1, a 2,…, a r ) Disjoint cycles
24
§5.4 – Permutation Functions Theorem 5.4.2 –A permutation of a finite set that is not the identity or a cycle can be written as a product of disjoint cycles of length greater than or equal to 2
25
§5.4 – Permutation Functions Transposition –Cycle of length 2 –Every cycle can be written as a product of transpositions as follows: (b 1, b 2, …, b r ) = (b 1, b r ) (b 1, b r-1 ) … (b 1, b 2 )
26
§5.4 – Permutation Functions Even permutation –A permutation that can be written as the product of an even number of transpositions Odd permutation –A permutation that can be written as the product of an odd number of transpositions
27
§5.4 – Permutation Functions Theorem 5.4.3 –A permutation cannot be both even and odd Theorem 5.4.4 –Let A = {a 1, a 2, …, a n }, with |A| = n 2. Then there are n!/2 even permutations of A, and n!/2 odd permutations of A.
28
§5.4 – Permutation Functions Transposition codes –Encrypt by using the following transposition MATH IS GREAT (1, 10, 7) (11, 3, 2, 8) (5, 4, 9) –Decrypt the following Message:OICLPCYIGULSOYRRVTTEA Transposition Code:(16, 15, 6, 1, 3, 7, 11, 2) (8, 13, 4, 5, 19) (14, 10) (21, 20, 17)
29
§5.4 – Permutation Functions Transposition codes –Keyword Columnar Transposition – Example 8 Using the keyword “JONES” to encrypt: THE FIFTH GOBLET CONTAINS THE GOLD Result: FGTAHDTFBONGEHETTLHTLNSOIOCIEX
30
§5.4 – Permutation Functions Transposition codes –Keyword Columnar Transposition Use the keyword “BASEBALL” to decrypt: AAK7ENWHRSOER9SAETOELNNWIDYELXBO1DXKTI3R Using a keyword columnar transposition
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.