这个伪代码的时间复杂度和Big-0是多少?

时间:2020-01-27 01:23:24

标签: for-loop time-complexity big-o pseudocode

算法squareRoot (k)

使用“巴比伦方法”估算k的平方根。

pre: k is an integer

returns: approximation of square root of k 
1:    guess ← 1.0                                   // ??

2:    for i from 0 to i<=100 do                     //??

3:       guess ← (guess + k/guess) / 2.0             //??

4:    done                                          // This has no running time of course

f(n)= ?
O(?) 

0 个答案:

没有答案