算法分析学习小结1

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“

输入规模:

例如:

  1. 输入中的项数 作为度量:待排序数组规模n
  2. 两数相乘:用二进制记号表示输入所需的总位数 作为度量
  3. 图:用顶点边数来描述输入规模

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

  • 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,Ω,Θ

几个重要推论:

  1. All logarithmic functions logan belong to the same class Θ(logn) no matter what the logarithm’s base a > 1 is
  2. 所有多项式以最高次项为主 aknk +ak−1nk−1 +···+a0 ∈Θ(nk)
  3. 指数需要考虑底数 Exponential functions
    这里写图片描述
    have different orders of growth for different a’s

  4. 这里写图片描述

这里写图片描述

3.递归分析!!

主定理

这里写图片描述

这里写图片描述

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值