algorithm - 重复 T(n) = T(n^(1/2)) + 1

标签 algorithm math big-o analysis recurrence

我一直在关注这种复发情况,想检查一下我是否采取了正确的方法。

T(n) = T(n^(1/2)) + 1
= T(n^(1/4)) + 1 + 1
= T(n^(1/8)) + 1 + 1 + 1
...
= 1 + 1 + 1 + ... + 1 (a total of rad n times)
= n^(1/2)

所以答案是 n^(1/2) 的 theta 边界

最佳答案

这里介绍了如何在没有任何提示的情况下仅使用数学就可以找到答案。

开始展开递归:enter image description here .

递归会在某个点停止,所以我们必须找到一个合理的停止点。尝试 0、1、2,你会发现 2 看起来不错,因为你可以很容易地求解方程:enter image description here .

解决它,你得到enter image description here .

因此递归将继续 log(log(n)) 次,这就是您的时间复杂度。

P.S. 解决了稍微难一点的复发问题here .

关于algorithm - 重复 T(n) = T(n^(1/2)) + 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9550455/

相关文章:

algorithm - 多少位足以用英文散列网页?

c - 求和给出随机错误数字

c++ - 分割 64 位值以适合 double 参数类型

search - 更喜欢哪种搜索算法?

c++ - 优化 Eigen 中的大型矩阵乘法

寻找包围一组点的两个平行平面的算法

javascript - 如何让 jQuery Accordion 返回到起始位置(目前在一个之上返回)

algorithm - 2^n 和 n*2^n 的时间复杂度相同吗?

algorithm - 哪种算法可以只用 O(N) 次移动来进行稳定的就地二进制分区?

c++ - 查找矩形外的网格起点