use*_*369 3 python big-o time-complexity
以下功能的"大O"是什么?我的假设是它是O(log(n)),但我想仔细检查.该函数简单地确定其参数是否为2的幂.
def pow_of_2(x):
a = math.log(x, 2)
if a == math.floor(a):
return True
else:
return False
Run Code Online (Sandbox Code Playgroud)