Why is the Big O characterizaion of this summation O(n^(n+1))?

40 Views Asked by At

If we have this summation

$$ \sum_{k=1}^n n^k $$

The time complexity of this function is O($n^{n+1}$). Why would that be? If I'm not mistaken this is a function which is the addition of n to all powers between 1 and n, meaning the term with the largest power, which dictates our time complexity, is $n^n$.

2

There are 2 best solutions below

0
On BEST ANSWER

$$\sum_{k=1}^n n^k = \frac{n^{n+1}-1}{n-1} = O(n^n)\ \text{as}\ n \to \infty$$ But that doesn't prevent it from being $O(n^{n+1})$.
Check the definition.

0
On

Remember that the notation $\mathcal{O}$ is additive. Wich means that :

$$\mathcal{O}(m+n) = \mathcal{O}(m) + \mathcal{O}(n)$$

Moreover note that we have :

$$\forall 0 \leq k \leq n, n^k = \mathcal{O}(n^n)$$

Hence we have :

$$\sum_{k = 1}^n n^k = \sum_{k = 1}^n \mathcal{O}(n^n) = \mathcal{O}\left(\sum_{k = 1}^n n^n\right) = \mathcal{O}\left(n^{n+1} \right)$$