Programmaticaly finding the Landau notation (Big O or Theta notation) of an algorithm?
- by Julien L
I'm used to search for the Landau (Big O, Theta...) notation of my algorithms by hand to make sure they are as optimized as they can be, but when the functions are getting really big and complex, it's taking way too much time to do it by hand. it's also prone to human errors.
I spent some time on Codility (coding/algo exercises), and noticed they will give you the Landau notation for your submitted solution (both in Time and Memory usage).
I was wondering how they do that...
How would you do it?
Is there another way besides Lexical Analysis or parsing of the code?
PS: This question concerns mainly PHP and or JavaScript, but I'm opened to any language and theory.