algorithm - Several big O notations for the same function -


let f(n)= ( (n^2+2n)/n + 1/1000*(n^(3/2)))*log(n)

the time complexity function both o(n²*log(n)) , o(n^(3/2)*log(n))

how possible? thought dominating term here n² (*log(n)) , therefore should o(n²*log(n)) big o notation , time complexity measures feels ambiguous

big o notation isn't confusing. defines upper bound running time of algorithm, hence, if o(f(n)) valid upper bound, every other o(g(n)) such g(n) > f(n) definitively valid, since if code run in less f(n), sure run in less g(n).

in case, since o(n^2 *log(n)) dominates o(n^(3/2) log(n)), it's valid upper bound too, if it's less strict. furthermore, algorithm o(n^3). question is, 1 of big o notation gives more informations algorithm? obvious answer lower one, , that's reason why indicate that.

to make things cler : let's can throw ball in air 10m. then, can can't throw higher 10m, or can't throw higher 15 meters. fact first 1 stricter upper bound, doesn't make second 1 false statement.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -