Lecture 2

advertisement

CSCI 248 Data Structures and Algorithms II

Growth of Functions, Asymptotic Notations (Chapter 3 of the textbook)

T(n) – running time function, n

{0,1,2,….}

O-notation

Definition : A function T(n) is said to be in O(g(n)) if there exist positive constants c and n o such that 0

T(n)

cg(n) for all n

n o

.

We write T(n)=O(g(n)).

O-notation describes an upper bound.

Examples:

1. Prove that 100n+5 = O(n

2

)

2. Prove that 3 n

 

( n log n )

- notation

Definition : A function T(n) is said to be in

(g(n)) if there exist positive constants c and n o such that 0

cg(n)

T(n) for all n

n o

.

We write T(n)=

(g(n)).

 

-notation describes an lower bound.

Example:

1.

Prove that n

3  

( n

2

)

- notation

Definition : A function T(n) is said to be in

(g(n)) if there exist positive constants c

1

, c

2,

and n o such that c

1 g(n)

T(n)

c

2 g(n) for all n

We write T(n)=

(g(n)).

 

-notation asymptotically bounds a function from above and below

n o

.

Example:

1. Prove that

1

2 n ( n

1 )

 

( n

2

)

Download