gpt4 book ai didi

algorithm - 编程/编码时渐近时间复杂度的意义?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:34:06 25 4
gpt4 key购买 nike

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

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

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 类(class)的算法单元中学习过,对于合适的排序算法,排序是 O(NlogN),或者在列表中查找元素是 O(N ) 平均。 (如果你没有学过算法单元,那么有很多好的教科书......)

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

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

关于algorithm - 编程/编码时渐近时间复杂度的意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33194941/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com