cs 23022 discrete mathematical structures

21
CS 23022 Discrete Mathematical Structures Mehdi Ghayoumi MSB rm 132 [email protected] Ofc hr: Thur, 9:30-11:30a

Upload: cyrus-ray

Post on 01-Jan-2016

47 views

Category:

Documents


1 download

DESCRIPTION

CS 23022 Discrete Mathematical Structures. Mehdi Ghayoumi MSB rm 132 [email protected] Ofc hr: Thur, 9:30-11:30a. Announcements. Homework 5 available. Due 06/26, 8a. Midterm 1: 06/30/14, Chapter 3 in Rosen and some other articles. Growth of functions - another theorem. If - PowerPoint PPT Presentation

TRANSCRIPT

CS 23022Discrete Mathematical Structures

Mehdi Ghayoumi

MSB rm 132

[email protected]

Ofc hr: Thur, 9:30-11:30a

Announcements

Homework 5 available. Due 06/26, 8a.

Midterm 1: 06/30/14,

Chapter 3 in Rosen and some other articles.

Growth of functions - another theorem

If

f1(x) = O(g1(x))

and

f2(x)=O(g2(x)),

then

f1(x)·f2(x) = O(g1(x)·g2(x))

Growth of functionsAlgorithm “Good Morning”

For I = 1 to n

For J = I+1 to n

Shake Hands(student(I), student(J))

Running time of “Good Morning”

Time = (# of HS) x (time/HS) + some overhead

We want an expression for T(n),

running time of “Good Morning” on input of size n.

Growth of functionsAlgorithm “Good Morning”

For I = 1 to n

For J = I+1 to n

ShakeHands(student(I), student(J))How many handshakes?

1 2 3 4 5 n

1

2

3

4

5

n

I

J1 2 3 4 5 n

1

2

3

4

5

n

1 2 3 4 5 n

1

2

3

4

5

n

n2 - n

2

Growth of functionsAlgorithm “Good Morning”

For I = 1 to n

For J = I+1 to n

ShakeHands(student(I), student(J))

T(n) = s(n2- n)/2 + t

Where s is time for one HS, and t is time for getting

organized.

= O(n2) if ShakeHands() runs in constant time.

Growth of functions

Use the definition of O-notation to express

|17x6 – 3x3 + 2x + 8| ≤ 30|x6|

for all x > 1

M = 30

x0 = 1

17x6 – 3x3 + 2x + 8 is O(x6)

Growth of functions

17x6 – 3x3 + 2x + 8

x6

30x6

Growth of functionsUse the definition of O-notation to express for all x > 6

M = 45x0 = 6

x

x

xx45

1

9215

xOxx

xx is 45

1

9215

Growth of functions

1

9215

x

xx

x45

x

xOxx

xx is 45

1

9215

O -notation

O(g(n)) = {f(n) :

positive constants c and n0,

such that

n n0,

we have

f(n) cg(n)}

For function g(n), we define O(g(n)), big-O of n, as the set:

-notation

(g(n)) = {f(n) :

positive constants c and n0,

such that

n n0,

we have 0 cg(n) f(n)}

For function g(n), we define (g(n)), big-Omega of n, as the set:

-notation

(g(n)) = {f(n) :

positive constants c1, c2, and n0,

such that

n n0,

we have 0 c1g(n) f(n) c2g(n)}

For function g(n),define (g(n)), big-Theta of n, as the set:

Growth of functions - other estimates

f = o(g)

“f is little-o of g”

o(g(n)) = {f(n) :

positive constants c>0 and n0,

such that

n n0,

we have 0 f(n) cg(n)

}

Growth of functions - other estimates

Example: Show that n2 = o(n2log n)

This inequality holds when n > 21/c.

Choose c arbitrarily. How large does n have to be so that n2 c n2log n?

1 c log n

1/c log n

21/c n So, k = 21/c.

Growth of functions - other estimates

Example:

Show that 10n2 = o(n3)

This inequality holds when n >

10/c.

Proof :

find a k (possibly in terms of c) that makes the inequality

hold.Choose c arbitrarily.

How large does n have to be so that

10n2 c n3?

10/c n So, k = 10/c.

Relations Between Q, O, W

Comparison of Functions

f g a b

f (n) = O(g(n)) a b

f (n) = (g(n)) a b

f (n) = (g(n)) a = b

f (n) = o(g(n)) a < b

Comparison of Functions

If

f(x) = O(g(x)),

and

f(x) = (g(x)),

then

f(x) = (x)

Comparison of Functions

“f is big-theta of g”

When we write f=O(g), it is like f g

When we write f= (g), it is like f g

When we write f= (g), it is like f = g.