CSCI 115 Chapter 5 Functions. CSCI 115 §5.1 Functions

  • View
    221

  • Download
    6

Embed Size (px)

Text of CSCI 115 Chapter 5 Functions. CSCI 115 §5.1 Functions

Math 115

CSCI 115Chapter 5FunctionsCSCI 1155.1Functions5.1 FunctionsFunctionRelation such that for every domain element a, |f(a)| = 1Mappings, transformationsf(a) = {b}f(a) = ba = argumentb = function value5.1 FunctionsTypes of functionsEverywhere definedOntoOne to one (11)1 1 CorrespondenceED, Onto, 11Invertible Functions5.1 FunctionsTheorem 5.1.1

5.1 FunctionsTheorem 5.1.2

5.1 FunctionsTheorem 5.1.4

5.1 Functions1-1 functions and cryptographyAllows coding AND decodingSubstitution codes

Table from Example 18 (p. 188)

CSCI 1155.2Functions for Computer Science5.2 Functions for Computer Sciencemodn (or modn)FactorialFloorCeilingBooleanHashingOthers5.2 Functions for Computer ScienceSetCollection of objectsAny element is unambiguously in the set or notCharacteristic functionFuzzy setsWhether or not an element is in the set may be fuzzyThe set of all rich people5.2 Functions for Computer ScienceFuzzy setsFunction f defined on a set having values in the interval [0, 1]If f(x) = 0, x is not in the setIf f(x) = 1, x is in the setIf 0 < f(x) < 1 then f(x) is the degree to which x is in the setDegree of membershipOrdinary sets are special cases of fuzzy sets5.2 Functions for Computer ScienceFuzzy set operationsTheorem 5.2.1 (Finding other degrees of membership)Let A and B be subsets of the same universal set U. Then:

5.2 Functions for Computer ScienceFuzzy LogicFuzzy predicatesValues can be true, false, or somewhere in betweenSchrodingers CatQuantum theory and computersApplicationsControl theoryElevator operationABS systems in carsExpert systemsCSCI 1155.3Growth of Functions5.3 Growth of FunctionsAlgorithmic AnalysisEfficiencyNumber of steps (running time)Comparison5.3 Growth of FunctionsDefinitionsLet 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)5.3 Growth of FunctionsDefinitionWe 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.1The relation is an equivalence relation.5.3 Growth of FunctionsEquivalence classes of Equivalence classes (called classes) consist of functions of the same orderOne class is said to be lower than another if any of the functions in the first is lower than any in the secondclasses provide the necessary information to do algorithmic analysis5.3 Growth of FunctionsImage from page 203 of the text

CSCI 1155.4Permutation Functions5.4 Permutation FunctionsPermutation1-1 correspondence from a set onto itself

Theorem 5.4.1If A = {a1, a2, , an} with |A| = n, then n! permutations of A5.4 Permutation FunctionsCycle of length rIf p(a1) = a2, p(a2) = a3, , p(ar-1) = ar and p(ar) = a1, this is called a cycle of length r, and is denoted (a1, a2,, ar)

Disjoint cycles5.4 Permutation FunctionsTheorem 5.4.2A 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 25.4 Permutation FunctionsTranspositionCycle of length 2

Every cycle can be written as a product of transpositions as follows:(b1, b2, , br) = (b1, br)(b1, br-1) (b1, b2)5.4 Permutation FunctionsEven permutationA permutation that can be written as the product of an even number of transpositions

Odd permutationA permutation that can be written as the product of an odd number of transpositions5.4 Permutation FunctionsTheorem 5.4.3A permutation cannot be both even and odd

Theorem 5.4.4Let A = {a1, a2, , an}, with |A| = n 2. Then there are n!/2 even permutations of A, and n!/2 odd permutations of A.5.4 Permutation FunctionsTransposition codesEncrypt 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)5.4 Permutation FunctionsTransposition codesKeyword Columnar Transposition Example 8Using the keyword JONES to encrypt:THE FIFTH GOBLET CONTAINS THE GOLD

Result:FGTAHDTFBONGEHETTLHTLNSOIOCIEX

5.4 Permutation FunctionsTransposition codesKeyword Columnar Transposition

Use the keyword BASEBALL to decrypt:

AAK7ENWHRSOER9SAETOELNNWIDYELXBO1DXKTI3R

Using a keyword columnar transposition