views:

224

answers:

3

I need to derive the Big-O complexity of this expression:

c^n + n*(log(n))^2 + (10*n)^c

where c is a constant and n is a variable.
I'm pretty sure I understand how to derive the Big-O complexity of each term individually, I just don't know how the Big-O complexity changes when the terms are combined like this.
Ideas?

Any help would be great, thanks.

+9  A: 

The O() notation considers the highest term; think about which one will dominate for very, very large values of n.

In your case, the highest term is c^n, actually; the others are essentially polynomial. So, it's exponential complexity.

Chris Jester-Young
+1 - Yep that's right. I deleted my answer. I read it as n^c for some reason.
Taylor Leese
One very important assumption: C has to be greater than 1. :-P
Chris Jester-Young
+3  A: 

Wikipedia is your friend:

In typical usage, the formal definition of O notation is not used directly; rather, the O notation for a function f(x) is derived by the following simplification rules:

  • If f(x) is a sum of several terms, the one with the largest growth rate is kept, and all others omitted.
  • If f(x) is a product of several factors, any constants (terms in the product that do not depend on x) are omitted.
RegDwight
I thought Google is :)
hab
+12  A: 

The answer depends on |c|

If |c| <= 1 it's O(n*(log(n))^2)

IF |c| > 1 it's O(c^n)

Maciej Hehl
+1 Yay for an answer that catches both cases of C's value. :-P
Chris Jester-Young
I never thought about this before, but here goes. If the complexity depends on the magnitude of C, does this mean it also depends on the units used to measure C?If not, what units should C be measured in?
Stewart
@Stewart I don't think c can be expressed in some units. If it could then the unit of the expression would depend on n and (10*n)^c wouldn't make much sense.
Maciej Hehl