简体   繁体   English

Big O 表示法是否值得时间复杂性或增长率?

[英]Is Big O notation merit Time Complexity or Rate of Growth?

I am studying Data Structures and Algorithms through internet and I learnt that;我正在通过互联网学习数据结构和算法,我学到了;

  • Time complexity is the amount of time taken by an algorithm to run, as a function of the length of the input时间复杂度是算法运行所花费的时间量,作为输入长度的 function
  • Big O notation is a metric for calculating time complexity and Big O 表示法是用于计算时间复杂度
  • Rate of Growth is the rate at which the cost of the algorithm grows as the size of its input grows.增长率是算法成本随着输入规模的增长而增长的速率。

Assume there is an algorithm which has a f(n) = n^2+3n+1 total number of operations.假设有一个算法,其操作总数为f(n) = n^2+3n+1 Then what would be the Time Complexity and Rate of growth if this algorithm?那么如果这个算法的时间复杂度和增长率是多少呢? Are both represent by O(n^2) ?都由O(n^2)表示吗?

It is not clear for me that what is the difference between Time Complexity and Rate of Growth when representing using Big O notation.我不清楚使用大 O 表示法表示时时间复杂度和增长率之间有什么区别。

Please help me to get a clear idea about the terms.请帮助我对条款有一个清晰的认识。 It'll be really appreciated.这将不胜感激。

Thank you in advance!先感谢您!

Big O describes both the rate of growth and the time complexity. Big O 描述增长率和时间复杂度。 However, as is mentioned in the comments, the former relates as a derivative.然而,正如评论中所提到的,前者是作为派生的。 As in the case of O(1), the time is constant so there is no dependent growth rate, but the time complexity is still 1.与 O(1) 的情况一样,时间是恒定的,因此没有相关的增长率,但时间复杂度仍然为 1。

In your case of an O(n^2) algorithm, the runtime (time complexity) will grow at the expected rate of n^2 (rate of growth).在您使用 O(n^2) 算法的情况下,运行时间(时间复杂度)将以 n^2 的预期速率(增长率)增长。

Also in this Quora post of roughly the same question, the answer states the "runtime depends on the current input size, and the growth rate describes how the runtime will increase as the input size grows."同样在Quora 的这篇大致相同问题的帖子中,答案指出“运行时间取决于当前的输入大小,而增长率描述了运行时间将如何随着输入大小的增长而增加。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM