algorithm - 计算 n 为 nlog(n) 和 n!当时间为 1 秒时。 (算法需要 f(n) 微秒)

标签 algorithm big-o clrs

给出了 CLRS 算法书中的以下问题。

For each function f (n) and time t in the following table, determine the largest size n of a problem that can be solved in time t, assuming that the algorithm to solve the problem takes f(n) microseconds.

  1. 当时间为 1 秒时,如何计算 f(n)=nlog(n) 的 n?
  2. 如何计算 f(n)=n 的 n!什么时候是 1 秒?

最佳答案

提到该算法需要 f(n) 微秒。那么,可以认为该算法由 f(n) 个步骤组成,每个步骤需要 1 微秒。

给出的问题表明相关的 f(n) 值受 1 秒的限制。 (即 106 微秒)然后,由于您正在寻找满足这些条件的最大 n 可能,您的问题归结为下面给出的不等式。

1) f(n) = nlog(n) <= 106

2) f(n) = n! <= 106

我认为剩下的主要是处理代数和对数方程来找到相关值。

关于algorithm - 计算 n 为 nlog(n) 和 n!当时间为 1 秒时。 (算法需要 f(n) 微秒),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39912029/

相关文章:

data-structures - 克隆二叉树的时间复杂度

complexity-theory - 了解大O

algorithm - n选2的复杂度在Theta(n^2)?

algorithm - 比赛括号放置算法

algorithm - 图 - 如何计算从 v1 到 v2 所需的最小 "broken roads"数量?

algorithm - 在二维数组中找到最短路线

java - 卡在一个带有随机数据轴的简单快速排序实现中

algorithm - 归并排序计算复杂度时 "cn"到底是什么?

algorithm - 了解 CLRS 上的通用哈希章节