Ch3 Algorithm
Algorithms
Introduction
An 算法(algorithm) is a finite set of precise instructions for performing a computation or for solving a problem.
Properties of Algorithms
算法一般都有一些共同性质,在描述与评价算法时这种性质是常用的。
- 输入(input):An algorithm has input values from a specified set.
- 输出(output):From each set of input values, an algorithm produces output values from a specified set.
- 确定性(definiteness):算法的每一步都应该被精确定义。The steps of an algorithm must be defined precisely.
- 正确性(correctness):算法应该给出正确的输出结果。An algorithm should produce the correct output values for each set of input values.
- 有限性(finiteness):算法应当在有限步内结束。An algorithm should produce the desired output after a finite number of steps for any input in the set.
- 有效性(effectiveness):算法的每一步都可以被有效执行。Each step of an algorithm must be executed exactly and in a finite amount of time.
- 通用性(generality):我们的算法应该对于任意符合条件的输入都应用,而不是只适用某些特定的输入。The procedure should be applicable for all problems of the desired form, not just for a particular set of input values.
correctness 和 effectiveness 辨析 ★
correctness 主要将算法应该给出 correct output values,而 effectiveness 则主要指出算法应当是可以被 exactly execute。作业题中有一题是一算法会出现 的情况,应该判定为缺少 effectiveness.
The Growth of Functions
Asymptotic Running Time
渐进运行时间(asymptotic running time) is the number of operations used by the algorithm as the input size approaches infinity.
Asymptotic Notation
大 O 记号(Big-O notation):Let and be functions from (or ) to . We say that “ is ” if there are constants and such that whenever .
大记号(Big-Omega notation):Let and be functions from (or ) to . We say that “ is ” if there are constants and such that whenever .
大记号(Big-Theta notation):Let and be functions from (or ) to . We say that “ is ” if “ is ” and “ is ”, i.e., there are constants , , and such that whenever .
Complexity of Algorithms

Commonly used Terminology for the Complexity of Algorithms
| Complexity | Terminology |
|---|---|
| 常数复杂度(constant complexity) | |
| 对数复杂度(logarithmic complexity) | |
| 线性复杂度(linear complexity) | |
| 多项式复杂度(polynomial complexity) | |
| 指数复杂度(exponential complexity) (b>1) | |
| 阶乘复杂度(factorial complexity) |
Comments