2^n + 6n^2 + 3n
I guess it's just O(2^n), using the highest order term, but what is the formal approach to go about proving this?
2^n + 6n^2 + 3n
I guess it's just O(2^n), using the highest order term, but what is the formal approach to go about proving this?
Please see:
Big O Notation Homework--Code Fragment Algorithm Analysis?
Big O, how do you calculate/approximate it?
Can someone please explain the difference between Big-O and Little-O Notation?
Big-O for Eight Year Olds? (not meant to be insulting)
You can prove that 2^n + n^2 + n = O(2^n)
by using limits at infinity. Specifically, f(n)
is O(g(n))
if lim (n->inf.) f(n)/g(n)
is finite.
lim (n->inf.) ((2^n + n^2 + n) / 2^n)
Since you have inf/inf, an indeterminate form, you can use L'Hopital's rule and differentiate the numerator and the denominator until you get something you can work with:
lim (n->inf.) ((ln(2)*2^n + 2n + 1) / (ln(2)*2^n))
lim (n->inf.) ((ln(2)*ln(2)*2^n + 2) / (ln(2)*ln(2)*2^n))
lim (n->inf.) ((ln(2)*ln(2)*ln(2)*2^n) / (ln(2)*ln(2)*ln(2)*2^n))
The limit is 1, so 2^n + n^2 + n
is indeed O(2^n)
.