我遇到了这个Python code,它计算二项式系数(n选择k)。那么这段代码的运行时间是O(n)吗?
cache = {}
def bi(n, k):
if (n, k) not in cache:
if k == 0:
cache[(n, k)] = 1
elif n == 0:
cache[(n, k)] = 0
else:
cache[(n, k)] = bi(n-1, k) + bi(n-1, k-1)
return cache[(n, k)]
print(bi(9,9))