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

2 Answers

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

You Might Also Like