# How to estimate the complexity of sequential algorithm given that we know the complexity of each step?

First case: I was stumble upon a two step sequential algorithm where the big O complexity of each step is $$O(N^9)$$.

Second case: Also if the algorithm have three steps where the complexity of step 1 is $$O(N^2)$$, the complexity of step 2 is $$O(N^3)$$ and the complexity of step 3 is $$O(N^9)$$

What would be the complexity of the first case and second case ?

In the first case, we have $$O(n^9)+O(n^9)$$ and according to it's summation properties we have $$O(n^9)+O(n^9)=O(2n^9)=O(n^9)$$.
For the second case, both $$n^2$$ and $$n^3$$ are smaller than $$n^9$$, so we have $$O(n^2)+O(n^3)+O(n^9)=O(n^2+n^3+n^9)
In the general case, if we have time complexities $$t_1,t_2,...,t_k$$, then $$O(t_1)+...+O(t_k)=O(max\{t_1,...,t_k\})$$
• In terms of complexity analysis its no different. In terms of actual running time - it will be an improvement, and the speedup will depend on the constants behind the $O(n^9)$ and the $O(n^2)$. Jun 22, 2020 at 17:00
• If you have changed a $0.00001n^9$ to a $999999999n^2$ then obviously thats not really an improvement Jun 22, 2020 at 17:01