您的位置:首页 > 其它

算法分析学习小结1

2016-03-24 17:07 423 查看

1.复杂度分析

Instance

An instance is obtained by specifying values for the various problem parameters.

The length of an instance is the input size of the instance represented by binary encoding.

The features of of an instance are the parameters describing the length of instances

1.空间复杂度

“Space Complexity of an algorithm is total space taken by the algorithm with respect to the input size or features of instances“

输入规模:

例如:

输入中的项数 作为度量:待排序数组规模n

两数相乘:用二进制记号表示输入所需的总位数 作为度量

图:用顶点边数来描述输入规模

运行一个程序的空间需求:

instruction space ( without relation to features of instances )

Data space

constants, simple temp variables ( without relation to features of instances )

composite variables: arrary, link tables, trees, graphs ( relate to features of instances )

Environment stack space(function calls)

non-recursive calls ( without relation to features of instances )

recursive calls ( relate to features of instances )

Space requirements for a program P can be rewritten as

S(P) = Sp(features) + constant (1)

where constant is the value without relation to features of instances

We only consider Sp(features) for analysis of space complexity

constant is ignored

For non-recursive algorithms,

We only need consider composite variables with repect to features of instances

The length of an instance is the input size of the instance represented by binary encoding.

composite variables

environment stack address

parameter variables

recursive deepth

2.时间复杂度

Factors affecting run time

Characteristics of the computer system (e.g. processor speed, amount of memory, file-system type, etc.)

Compile system

The way the algorithm is implemented (sequential or paralle )

The particular instance of data the algorithm is operating on ( e.g. amount of data, type of data)

Have some assumptions help to analysis time complexity

The characteristics of the particular computer system are considered irrelevant

compile time and implementation are also ignored.

Each instruction is considered to take one “unit” of time.

Some simple measure of the“size”of the data is made

We use the the number of instructions executed as measure of time complexity.

step:

1. primitive operators

2. T(n)=

Theorem

if c1 < time for a primitive steps < c2

then c1T(n) < real time for an algorithm < c2T(n)

The definition of primitive steps is not unique

BAW

Best case

Average case

Worst case

3.渐进符号

O(g(n)): class of functions f(n) that grow no faster than g(n)

Θ(g(n)): class of functions f(n) that grow at same rate as g(n)

Ω(g(n)): class of functions f(n) that grow at least as fast as g(n)

可用公式

1. L’Hôpital’s rule

2. Stirling’s formula

几个有用的渐进




where ⊕ can be any one of O,Ω,Θ



where ⊕ can be any one of O,Ω,Θ

几个重要推论:

All logarithmic functions logan belong to the same class Θ(logn) no matter what the logarithm’s base a > 1 is

所有多项式以最高次项为主 aknk +ak−1nk−1 +···+a0 ∈Θ(nk)

指数需要考虑底数 Exponential functions



have different orders of growth for different a’s





3.递归分析!!

主定理





内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: