Name: Anonymous 2013-06-17 23:43
Is there a program or a library that I could use to find the O() of an algorithm? For example,
Is there a library that would work as O(f) should?
def O_1(n):
return n
def O_n(n):
s = 0
for i in range(0, n):
s = s + i
return s
def O_n2(n):
m = 1
for i in range(1, n + 1):
for j in range(1, n + 1):
m = m * i * j
return m
print("O(O_1()) = " + O(O_1) ) # O(O_1()) = O(1)
print("O(O_n()) = " + O(O_n) ) # O(O_n()) = O(n)
print("O(O_n2()) = " + O(O_n2) ) # O(O_n2()) = O(n^2)Is there a library that would work as O(f) should?