文章目录
算法知识整理-Knowledge of Algorithm Summary
算法定义-Definition of Algorithm
算法:算法能够对一定规范输入,在有限时间内获得有效输出
Algorithm: algorithm is a step by step procedure, which defines a set of instructions to be executed in a certain order to get the desired output.
算法特征-Characteristic of Algorithm
- 有穷性-Finiteness:
Algorithm must terminate after a finite time of steps - 可行性-Feasibility:
Algorithm should be feasible with the avaliable resources - 确定性-Unambiguous
Each of its steps should be clear and must lead to only one meaning - 输入-Input
Should have 0 or more well-defined inputs - 输出-Output
Should have at least 1 well-defined outputs - 独立性-Independace
Should be independent of any programming codes
数据结构中的算法-Algorithms in data structure
- 搜索-Search
- 排序-Sort
- 插入-Insert
- 删除-Delete
- 更新-Update
算法复杂度-Algorithm Complexity
- 时间复杂度
- time factor:
counting the numbers of key operations
计算关键步骤所用的时间,如排序算法中的比较 - time complexity
the amount of time required by the algorithm to run to completion
执行算法所需要的时间 - Asymptotic Analysis & Asymptotic Notation
Ways to calculate time complexity
渐进性表示方法
O ( n ) O(n) O(n) - upper bound
Ω ( n ) \Omega(n) Ω(n) - lower bound
θ ( n ) \theta(n) θ(n) - both upper and lower bound
- time factor:
- 空间复杂度
- space factor
counting the maximum memory space required by the algorithm - space complexity
the amount of memory space required by the algorithm in its life cycle- fixed part: independent of the size of the problem
- variable part: depends on the size of the problem
[example: dynamic memory allowcation, recursion stack space]
- space factor