sqrt(n)
Write a python program with a time complexity of f(n) = sqrt(n)
and class O(sqrt(n))
1p, i = 0, 0
2while p < n:
3 p = p + i
4 i += 1
i | p |
---|---|
0 | 0+1 |
1 | 1+2 |
2 | 1+2+3 |
3 | 1+2+3+4 |
n | 1+2+3+4+n |
Write a python program with a time complexity of f(n) = sqrt(n)
and class O(sqrt(n))
1p, i = 0, 0
2while p < n:
3 p = p + i
4 i += 1
i | p |
---|---|
0 | 0+1 |
1 | 1+2 |
2 | 1+2+3 |
3 | 1+2+3+4 |
n | 1+2+3+4+n |