Connecting Tech Pros Worldwide Help | Site Map

time complexity

Newbie
 
Join Date: Sep 2009
Posts: 1
#1: Sep 7 '09
is there any algorithm that can find time complexity of any program(recursive or non recursive)?
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Sep 7 '09

re: time complexity


Quote:

Originally Posted by amana View Post

is there any algorithm that can find time complexity of any program(recursive or non recursive)?

No there isn't and the proof is analogous to the Turing Halting Problem proof:

suppose you have such an algorithm A(P) such that A(P) == O(f(n)) which indicates the big-Oh value of P. Consider this P:

P(n): if A(P) == O(n) then do something O(2^n) else do something O(n)

kind regards,

Jos
Reply