chapter 2 : The Complexity of Algorithms and the Lower Bounds of Problems

 

Definition (complexity)

The space complexity of an algorithm is the amount of memory it needs to run to completion.
The time complexity of an algorithm is the amount of computer time it needs to run to completion.
分析算法所需的时间时,不适合用实际的时间来表示,因为每台电脑的执行速度都不相同。
program step 表示一 program 执行时间 statement 都算一次。
For instance: return (a + b + b´c + (a+b-c)/(a+b) + 4.0); 作是一 program step
可以在每 statement 的地方加一 counter (global variable),就可以实际算出每算法的执行步骤
赋值语句算一个statement
return s 算一个statement。 

你可能感兴趣的:(Algorithm,算法)