I am confused as to how this is true: O(n log n) + mO(log n) = O((m + n) log n)
I understand that O(n) + O(m) = O(n + m). I'm mostly confused as to how to deal with the coefficient preceding O(log n).
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.
Sign up to join this communityI am confused as to how this is true: O(n log n) + mO(log n) = O((m + n) log n)
I understand that O(n) + O(m) = O(n + m). I'm mostly confused as to how to deal with the coefficient preceding O(log n).
We can prove that if $f(n)$ is $O(\log{n})$ and $g(m)$ is $O(m)$ then $f(n)g(m)$ is $O(m \log{n})$. To say that $mO(\log{n}) = O(m \log{n}))$ is an abuse of notation.
See Wikipedia for similar properties of big O: http://en.wikipedia.org/wiki/Big_O_notation#Properties.