# Mathematical Foundation - Computer Science and lai.1/6331/1.0.introduction.pdf Asymptotic Notation with Multiple Parameters cm n f fmn gcmn m m n ... We write iff there exist positive

• View
2

0

Embed Size (px)

### Text of Mathematical Foundation - Computer Science and lai.1/6331/1.0.introduction.pdf Asymptotic Notation...

• Mathematical Foundation

CSE 6331 Algorithms Steve Lai

• Analysis of algorithm: to predict the running time required by an algorithm. Elementary operations:

arithmetic & boolean operations: +, , ×, /, mod, div,

Complexity of Algorithms

− −

and, or comparison: if , if , etc. branching: go to assignment: and so on

a b a b

a b

− < = − − ← −

2

• The of an algorithm is the number of elementary operations required for the algorithm. It depends on the size of the input and the data

themselves. Th

running time

worst-case time co p ee m l

• of an algorithm is a function of the input size : ( ) = the worst case running time over

xity

asymp

a

to

ll i

tic

nstances of size . The worst-case time complexity is the worst

case time

n T n

n •

complexity expressed in , , or . asymptotThe word is often omiic tted.

O Ω Θ •

3

• Note: Unless otherwise stated, all functions considered in this class are assumed to be nonnegative. Conventional Definition ( ) ( ( )) : We say or

( ) ( ( )) if th re e e

O-Notation

f n O g n f n is O g n

• =

0 0

xist constants and such that ( ) ( ) for all . More Abstract Definition:

( ) : ( ) ( ( )) in the ( ( )) ,

conventional meaning

positive

i.e.,

c n f n cg n n n

f n f n O g n O g n

≤ ≥

=

  =  

  ( (the )) set of in the all functio

convent ns

ional meaning. that are O g n

4

• 2 2

2 2

2 2

2 2

These expressions all mean the same thing: 4 3 ( ) 4 3 is ( ) 4 3 ( ) 4 3 is in ( ). Sometimes ( ( )) is used to mean some function

in

n n O n n n O n n n O n n n O n

O g n

+ =

+

+ ∈

+

2

the set ( ( )) which we don't care to specify. Example: we may write:

Let ( ) = 3 (log ) .

O g n

f n n O n+ •

5

• 1 1 2 2

1 2 1 2

1 2 1 2

1 2 1 2

If ( ) ( ( )) and ( ) ( ( )), then 1. ( ) ( ) ( ( ) ( )) 2. ( ) ( ) (max( ( ), ( ))) 3. ( ) · ( ) ( ( ) · ( ))

There exP iroof. st

Theorem 1 f n O g n f n O g n

f n f n O g n g n f n f n O g n g n f n f n O g n g n

= = + = + + =

=

1 2

1 1 1 2 2 2

1 2 1 1 2 2

1 2 1 2

positive constants , such that ( ) ( ) and ( ) ( ) for sufficiently large .

Thus, ( ) + ( ) ( ) + ( ) ( + ) ( ( ) + ( ))

c c f n c g n f n c g n n

f n f n c g n c g n c c g n g n

≤ ≤ ≤ ≤

1 2 1 2 2( + ) max( ( ), ( )). By definition, 1 and 2 hold. 3 can be proved similarly.

c c g n g n≤

6

• 0

0

Conventional Definition: We say if there exist constants and such that ( ) ( ) for all .

Or define

positive

( ( )) as a set:

( ( )

( ) (

)

)

( )

-Notation

c n f n cg n n n

g

f n

n

g

g n

n

≥ ≥

• =

1 1 2 2

1 2 1 2

1 2

( ) : ( ) ( ( )) in the

conventional meaning

Theorem 2: If ( ) ( ( )) and ( ) ( ( )), then 1. ( ) ( ) ( ( ) ( )) 2. ( ) ( ) (ma

f n f n g n

f n g n f n g n f n f n g n g n f n f n

= Ω  =  

 

= Ω = Ω + = Ω + +

= Ω

1 2

1 2 1 2

x( ( ), ( ))) 3. ( ) · ( ) ( ( ) · ( ))

g n g n f n f n g n g n= Ω

7

• 1 2 0

1 2 0

positi Conventional Definition: We say if

there exist constants , , and such that (

( ) ( ( ))

( ) ( ) ( ) ( ) for all . That is,

( )) ( ) ( ( ))

v

a

e

-Notation

c c n c g

f n g n

f n g n f n c g n n n

n f n O g n≡

= Θ

= Θ

=

Θ

[ ]

1 1 2 2

1 2 1 2

1 2

.

In terms of sets:

Theorem 3: If ( ) ( ( )) and ( ) ( ( )), then 1. (

( ( )

) ( ) ( ( ) ( )) 2.

nd ( ) ( ( ))

)

( )

( ( )) (

( )

( ))

f n g n f n g n f n f n g n g n

g n O g n g

f n g n

n

f n f n

= Θ = Θ +

Θ

= Θ +

+

=

=

Θ

=

1 2

1 2 1 2

(max( ( ), ( ))) 3. ( ) · ( ) ( ( ) · ( ))

g n g n f n f n g n g n= Θ

8

• Definition of

( ) ( ) ( ( )) iff lim = 0. ( )

Definition of

( ) ( ) ( ( )) iff lim = . ( )

-Notation, -Notation

n

n

o

f nf n o g n g n

f nf n g n g n

o

ω

ω

ω

→∞

→∞

=

= ∞

9

• Transitive property: If ( ) ( ( )) and ( ) ( ( )),

then ( ) ( ( )).

The transitive property also holds for and .

( ) ( ( )) ( ) ( ( )).

Some Properties of Asymptotic Notation f n O g n g n O h n

f n O h n

f n O g n g n f n

= =

=

Ω Θ

= ⇔ = Ω

See the textbook for many others.•

10

• 0 0

0 0

Definition: We say that iff

there are positive constants , , such that

( , ) ( , ) for all

( , ) = ( ( ,

and .

))

A

Asymptotic Notation with Multiple Parameters

c m n

f

f m n cg m n m m n

m n O g m

n

n

gain, we can define ( ( , )) as a set.

( ( , )) and ( ( , )) can be similarly defined.

O g m n

g m n g m nΩ Θ•

11

• 0

0

Let ( ) be a predicate. We write iff there exist positive constants , such that ( ) ( ) for all for which ( ) is true.

( )

Can

( ( ) | ( )

si

)

m

Conditional Asymptotic Notation P n

c n T n c T n O f n P n

f n n n P n

= ≤

2

2

ilarly define and

Example: Suppose for 0,

4 2 if is even ( )

3 if is odd

Then, ( ) ( |

( ( ) | ( )) ( ( ) |

is eve

(

n

)

)

).f n P n

n

n n n T n

n n

T n

n P n

n n

fΩ

 + =  

= Θ

Θ

12

• 2

A function ( ) is iff ( ) is asymptotically nondecreasing and (2 ) ( ( )).

Thus, a smooth function does not grow very fast.

Example: log , log , are all smoot

Smooth Functions f n f n

f n O f n

n n n n

= •

smooth

h.

13

• Theorem 4.

Proof.

If ( ) is smooth, then ( ) ( ( )) for any fixed positive integer .

By induction on . For 1, 2, obviouInduction base:

Induction hypot sly ( ) ( ( )).

h

f n f bn O f n b

b b f bn O f n

=

=

=

( )

( ) ( )( ) ( ) ( )1 1 2

Assume ( 1) ( ( )), where 2. Need to show . We have:

2( 1) ( 1)

esis:

Induction

(i.e., ( ) 2( 1) ( 1) (

( ) ( ( ))

( ) ( ( ))

) for so

s p

e

e

t

m

: f bn O f n

f bn O f n

f b n O f n b

f b n O f b n

f bn f b n c f b n c c f n

− =

>

≤ − = − ⊆

≤ − ≤ −

=

1 2constants , and sufficiently large ). The theorem is proved.

c c n

14

• where 2 is a constant, ( ) is asymptotically nondecreasing and ( ) is smooth,

If ( ) ( ( ) | a power of ),

then ( ) ( ( )).

Theorem 5.

Proof.

From the given conditions, we know:

T n O f n n b

T n O f b T n

nf n ≥

=

• =

1

2 1

1. ( ) is asymptotically nondecreasing. 2. ( ) ( ) for sufficientl
{"ft_lang_label":"__label__en","ft_lang_prob":0.7117531,"math_prob":0.99893826,"size":5690,"snap":"2022-05-2022-21","text_gpt3_token_len":2437,"char_repetition_ratio":0.19222651,"word_repetition_ratio":0.27242154,"special_character_ratio":0.48752198,"punctuation_ratio":0.112443775,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99970627,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-29T00:21:34Z\",\"WARC-Record-ID\":\"<urn:uuid:725e49f4-0719-4638-bd4c-2f135b5df1d0>\",\"Content-Length\":\"112259\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8172f272-7560-4310-911a-3ba036a2f7c6>\",\"WARC-Concurrent-To\":\"<urn:uuid:d76a01ed-315b-4869-82d2-d9f793473312>\",\"WARC-IP-Address\":\"162.159.138.85\",\"WARC-Target-URI\":\"https://dokumen.tips/documents/mathematical-foundation-computer-science-and-lai1633110introductionpdf-asymptotic.html\",\"WARC-Payload-Digest\":\"sha1:JF2MZ2NSWGS7UBFWC6QVWML4RGOIEPOS\",\"WARC-Block-Digest\":\"sha1:UPZWSQDZ2LYXVX3IFZWRJSGXEJASKQTX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652663021405.92_warc_CC-MAIN-20220528220030-20220529010030-00153.warc.gz\"}"}