算法分析之函数渐近分析

首要原则,三点:

#1 最坏的情况分析。"worst – case analysis" : our running time bound holds for every input of length n.

BONUS : worst case usually easier to analyze.

#2 不关心常数。低阶项。Won't pay much attention to constant factors, lower-order terms

#3 渐近分析。Asymptotic Analysis: focus on running time for large input sizes n

Justification: Only big problems are interesting!

 

 

渐近分析。Asymptotic Analysis

上图即原则#2.

Example: Equate 6n log2(n) + 6 with just n log n.

Terminology: Running time is O (n log n) ["big-Oh" of n log n]

where n = input size (e.g. length of input array).

Examples:

Loops:O (n)    Two Nested Loops:O (n^2)

 

Big-O-notation

O-notation is an asymptotic upper bound.

大O里的内容表示函数渐近上界。

Basic Examples:

#1:    

#2:    

 

Omega-notation

Ω-notation provides an asymptotic lower bound.

Omega里的内容表示函数渐近下界。

 

Theta-notation

We say that g(n) is an asymptotically tight bound for f (n).

Theta里的内容取不同的两个系数可表示函数渐近上、下界。

看三者关系:

 

Little o-notation

We use o-notation to denote an upper bound that is not asymptotically tight.

小o表示非渐近紧确的上界。而大O可能是也可能不是渐近紧确的。

而上面例子,小o换成大O都成立。

小o就是函数极限的定义符号。

 

w-notation

小w表示非渐近紧确的下界。和小o定义相反。因此:

 

Examples

#1

#2

#3

 


 

ANNOUNCEMENTS:
DO NOT USE THE CONTENTS OF THIS BOLG FOR COMMERCIAL PURPOSE, AND I USE THE CONTENTS FORM INFERENCES JUST FOR STUY.
THIS BOLG IS FORM: http://www.cnblogs.com/JayZen/p/4073235.html 


Referances

Course: Algorithms: Design and Analysis, Part 1 by Tim Roughgarden at Stanford from Coursera

《Introduction to Algorithms》

posted @ 2014-11-04 11:33  Jay Zen  阅读(2722)  评论(0编辑  收藏  举报