Is $O(m \log n + n \log n )$ equal to $O((m+n) \log n )$?

272 Views Asked by At

I have a self study question and maybe very simple.

Can we conclude the following is true? Is it a property of asymptotic or log property?

$O(m \log n + n \log n )$ is equal to $O((m+n) \log n )$?

1

There are 1 best solutions below

1
On BEST ANSWER

If you look at the expression

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

this is just factoring the expression since

$$ m \log(n) + n \log(n) = (m+n)\log(n) $$

You'd probably be interested in the relationship between $m$ and $n$. Which one is larger?