您的位置:首页 > 编程语言 > Go语言

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

2009-11-16 17:53 671 查看
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。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐