Big-O multiplied by Big-Theta

1.4k Views Asked by At

I have an algorithm that iterates for $\Theta(n)$ steps. Each step has a complexity $O(n^2)$.

The complexity of the algorithm is then given as $\Theta(n) \times O(n^2) = ?$

Is it valid to multiply Big-Theta and Big-O? If so, what is the product of the $\Theta(n) \times O(n^2)$? Since Big-O ignores all lower-order terms, my gut is telling me that it is just equal to $O(n^2)$.

1

There are 1 best solutions below

5
On BEST ANSWER

It will be $O(n^3)$, and you cannot do any better as $f(n)= n$ is $\Theta(n)$ and $g(n) = n^2$ is $O(n^2)$ and their product is even $\Theta(n^3)$.