time complexity - Is there any algorithm whose big O and big theta are different? -


is there algorithm big o , big theta different? found them quite similar , confusing @ same time.

i think part of confusion here stems fact algorithms don't have "a big-o" or "a big-theta." o , θ notation used describe long-term growth rates of functions, rather algorithms. when hear "binary search o(log n)," they're saying "the runtime of binary search o(log n)" or "the worst-case runtime of binary search on input of length n o(log n)."

the other reason can confusing 1 function can big-o of number of different functions. example, function f(n) = n o(n), it's o(n2), o(n3), o(2n), etc. stems formal definition of big-o notation, says f(n) = o(g(n)) if (intuitively) in long term f(n) bounded above constant multiple of g(n). means can't speak of "the" big-o of function's runtime, since there can infinitely many functions might fit bill.

what can following: if function's runtime θ(f(n)), function's runtime o(f(n)). follows definition of θ notation. on other hand, converse isn't true; if function has runtime o(f(n)), it's not case function's runtime θ(f(n)). can use binary search example - binary search runs in time o(log n), runtime o(n) , o(n2) because weaker bounds. however, runtime of binary search not θ(n), nor θ(n2) or θ(2n).


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -