# cs 23022 discrete mathematical structures

Post on 02-Jan-2016

32 views

Category:

## Documents

Embed Size (px)

DESCRIPTION

CS 23022 Discrete Mathematical Structures. Mehdi Ghayoumi MSB rm 132 mghayoum@kent.edu Ofc hr: Thur, 9:30-11:30a. Announcements. Homework 4 available. Due Mon 06/23 , 8a. Midterm : Next Mon 06/30/14, location 121 . Chapter 2.3 in Rosen and some other articles And Chapter 3 in Rosen. - PowerPoint PPT Presentation

TRANSCRIPT

PowerPoint Presentation

CS 23022Discrete Mathematical StructuresMehdi GhayoumiMSB rm 132mghayoum@kent.edu Ofc hr: Thur, 9:30-11:30a

AnnouncementsHomework 4 available. Due Mon 06/23, 8a.Midterm : Next Mon 06/30/14, location 121.Chapter 2.3 in Rosen and some other articlesAnd Chapter 3 in Rosen

Familiar functionsPolynomials:f(x) = a0xn + a1xn-1 + + an-1x1 + anx0

constants (like 3, -20, or ) variables (like x and y)exponents (like the 2 in y2), but only 0, 1, 2, 3, ... etc. are allowedA polynomial can have:A polynomial can have constants, variables and exponents, but never division by a variable.

Familiar functions

DegreeStandard Form

Familiar functionsExponentials:

The exponential function with base b is defined by:

Familiar functionsNatural Exponential Function:

This function is simply a "version" of

where b >1.

Familiar functionsInverse of f (x) = ex: set the equation equal to y swap the x and y solve for y by rewriting in log form log base e is called the natural log, lnSince f (x) = ex is a one-to-one function, we know that its inverse will also be a function.But what is the equation of the inverse of f (x) = ex ?To solve for an inverse algebraically:

Familiar functions

Other Exponential Inverses:

Y=2x or y= 0.5x

Familiar functionsLogarithms:log2 x = y, where 2y = x.In this course, log2 n is written lg n. If we write log n, assume log2 n.f(x) = loga(x)a is any value greater than 0, except 1

Example: f(x) = log(x)

Example: f(x) = log2(x)

Familiar functionsloga(x) is the Inverse Function of ax (the Exponential Function)InverseThe Natural Logarithm FunctionThis is the "Natural" Logarithm Function:f(x) = loge(x)Where e is "Eulers Number" = 2.718281828459 (and more ...)

Familiar functionsCeiling:f(x) = x the least integer y so that x y.

Ex: 1.2 = 2; -1.2 = -1; 1 = 1

Familiar functionsFloor:f(x) = x the greatest integer y so that x y.

Ex: 1.8 = 1; -1.8 = -2; -5 = -5

Familiar functionsLinear Function

f(x) = mx + bSquare Function

Cube Functionf(x) = x2

f(x) = x3

Familiar functionsSquare Root Function

f(x) = xAbsolute Value Function

f(x) = |x|Reciprocal Function

f(x) = 1/x

Familiar functionsLogarithmic Function

f(x) = ln(x)Exponential Function

f(x) = ex

Familiar functionsDance Moves

Function typesDescribe these functions:

f(x)

x

Every unit increase in x results in the same increase in f(x).Linear functions

Function typesDescribe this function:

Very slow growing.Logarithmic function

Function typesDescribe this function:

Very fast growing.Exponential function

Function typesDescribe this function:

f(x)

x

Polynomial

Two example algorithmsSuppose we wish to find the maximum number in a sequence of n numbers.How long should we spend doing this?

We say the algorithm has order n running time.In this case our algorithm takes about n time units.Suppose it takes 1 time unit to make a comparison between two numbers.

Two example algorithmsI have a number between 0 and 63. You ask a question, Ill tell you yes or no.How long will it take you to find my secret number?

Suppose it takes 1 time unit to answer a query about my number.

In this case the algorithm takes about lg n time units.We say the algorithm has order log n running time.

Who wins the race?The following graph gives times for completing races of length x, for 4 different competitors.

Who is the tortoise?time

distance

Who is the hare?How would you describe blues performance?At each distance, who wins?

Growth of functionsAlgorithm analysis is concerned with:

Type of function that describes run time (we ignore constant factors since different machines have different speed/cycle)Large values of x

Growth of functionsImportant definition:

For functions f and g we write

f(x) = O(g(x))to denote

c,k so that x>k, f(x) cg(x)We say f(x) is big O of g(x)Recipe for proving f(x) = O(g(x)): find a c and k so that the inequality holds.

Growth of functionsf(x) = O(g(x)) iff c,k so that x>k, f(x) cg(x)x

f(x)

g(x)

cg(x)

k

We give an eventual upper bound on f(x)

Growth of functions (examples)f(x) = O(g(x))

Iff

c,k so that x>k, f(x) cg(x)3n = O(15n) since n>0, 3n 115n Theres kTheres c

Growth of functions (examples)f(x) = O(g(x))iff c,k so that x>k, f(x) cg(x)15n = O(3n) since n>__, 15n __3n 5805

Growth of functions (examples)f(x) = O(g(x))iff c,k so that x>k, f(x) cg(x)x2 = O(x3) since x> __, x2 x3 1

Growth of functions (examples)f(x) = O(g(x))iff c,k so that x>k, f(x) cg(x)1000x2 = O(x2) since x> __, 1000x2 ____x2 01000

Growth of functions (examples)f(x)=O(x4).

Growth of functions (examples)Prove that 5x + 100 = O(x/2)Nothing works for kNeed x> ___, 5x + 100 ___ x/2Try c = 10 x> ___, 5x + 100 10 x/2k = 200, c = 11Try c = 11 x> ___, 5x + 100 5x + x/2 x> ___, 100 x/2 200

Growth of functionsGuidelines:In general, only the largest term in a sum matters. a0xn + a1xn-1 + + an-1x1 + anx0 = O(xn)n5lg n = O(n6)

List of common functions in increasing O() order:1 (lg n ) n (n lg n) n2 2n n!

Growth of functions (more examples) Then

So

Growth of functions - a corollaryIf f1(x) = O(g1(x)) and f2(x)=O(g2(x)), then f1(x) + f2(x) = O(max{g1(x),g2(x)})

This is just the case where g1(x) = g2(x) = g(x)If f1(x) = O(g(x)) and f2(x)=O(g(x)), then f1(x) + f2(x) = O(g(x)).