算法分析学习小结1
2016-03-24 17:07
423 查看
1.复杂度分析
InstanceAn 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 < c2then c1T(n) < real time for an algorithm < c2T(n)
The definition of primitive steps is not unique
BAW
Best caseAverage 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.递归分析!!
主定理相关文章推荐
- C++标准库 vector排序
- 延时
- redmine新建问题速度慢
- 破解某Wifi APP,无需Root也可查看密码
- appium – 使用resource id定位
- TCP 系统调用
- python3.0以上 web crawled
- 知名圈子人李帅走访深圳国盛融金公司
- component不能正常显示
- centos安装redis3.0.0集群
- AFNetworking从1.0 到2。0的转换
- redis初步使用
- python 安装setuptools和pip
- 用户、角色、权限数据库设计
- 聊聊并发(一)——深入分析Volatile的实现原理
- 一半在外的按钮布局效果实现
- hdu2018java
- leetcode 179. Largest Number
- 第一次接触Web HighCharts 呵呵 Hello一下
- 4.1