Is There a Tool to Automatically Calculate Big-O Complexity for a Function [Duplicate]

While studying algorithms and data structures I manually evaluate BigO complexity for my script. Is there a way, let say a button in any Python IDE or a package, to calculate BigO for any given function or a program?

UPDATE:

Let's say I have

def print_first_element(a):
    print a[0]

why I can't write the analyzer which will say me ok you access the array (list) by index and its O(1), or

def print_all_element_of_list(a):
    for i in a:
        print i

ok you have full scan so the complexity is O(n)

and so forth

4

Unfortunately, infeasible. See Halting Problem.

1

It's not possible in general. Here's one python program that can compute the complexity for some program:

2
James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest