Programming/Coding时渐近时间复杂度的意义?

Significance of Asymptotic Time complexity while Programming/Coding?

我听说过很多关于时间的事 complexity.Time 复杂度本身就是一个近似值,因为我们关心的是最坏情况(Big-Oh)、最佳情况(Big-Omega) 和平均情况(Theta)。

每种编程语言都包含很多内置函数functions.I真的不知道是否有办法检查这些函数的时间复杂度。 由于我们使用内置函数,

Do we really need to Consider the Time complexity while coding? What about the space complexity?

Is there any way to check the time complexity of these functions. Since we are using buit-in-functions?

Do we really need to Consider the Time complexity while coding?

如果您的应用程序需要能够扩展到更大的问题,那么可以。否则没有。

What about the space complexity?

相同的答案。

Is there any way to check the time complexity of these functions. Since we are using built-in-functions?

  1. 阅读文档。标准 类 方法的复杂性经常被记录下来。

  2. 运用您的算法知识。例如,您应该在 CS 课程的算法单元中了解到,对于体面的排序算法,排序是 O(NlogN),或者在列表中查找元素平均是 O(N)。 (如果你没学过algorithmics uint,有很多好的教科书...)

  3. 检查并在必要时分析内置函数的源代码。

(注意:我不推荐 "empirical" 估计复杂性的方法。它会给你错误的答案......甚至忽略测量方法的标准问题。)

Is there any way to check the time complexity of these functions. Since we are using built-in-functions?

是的。
最常见的方法是 运行 循环(10,000 - 10,000,000 次,取决于定时器的功能、软件、精度等)与定时器(前后时间戳、秒表等)然后比较它给你的其他选择。

编辑:
您需要使用许多不同的输入大小,并注意缓存对测量的潜在混淆影响。