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

来源:互联网 发布:都市年轻人养猫数据 编辑:程序博客网 时间:2024/04/27 18:02

 

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),就可以实际算出每算法的执行步骤
program step
赋值语句算一个statement
return s 算一个statement。 
原创粉丝点击