
January 22nd, 2010, 09:48 PM
#1
how is O(logm+logn) = O(log(m+n))? O is big oh.
Hi guys,
Please help me understand this.
The professor in my university says that.
O(logm+logn) = O(log(m+n))?
How is that?
Thanks

January 22nd, 2010, 09:56 PM
#2
Re: how is O(logm+logn) = O(log(m+n))? O is big oh.
Because they are both logarithmic time.
gg

January 22nd, 2010, 10:19 PM
#3
Re: how is O(logm+logn) = O(log(m+n))? O is big oh.
Thanks for the reply. But can you elaborate on that. I didnt understand.

January 22nd, 2010, 11:15 PM
#4
Re: how is O(logm+logn) = O(log(m+n))? O is big oh.
You expected O(log(M)+log(N)) to be equivalent to O(log(M*N)) right?
It's true that log(M)+log(N) can be algebraically manipulated into log(M*N) but BigO is not an algebra, it's a notation.
O(log(M)+log(N)) expresses that the algorithm reacts logarithmically to M as well as to N. Regardless of which you vary or both, the algorithm will respond logarithmically. So the overall complexity is logarithmic and this is also expressed by O(log(M+N)). When M and N varies the overall response is logarithmic.
Lets say that M and N varies together. Then you can replace M with N. In the first case you get
O(log(N) + log(N)) = O(2*logN) = O(logN)
And in the second case you have
O(log(N + N)) = O(log(2*N)) = O(log(N))
In BigO both O(2*logN) and O(log(2*N)) expresses the same overall complexity, namely O(log(N)). You can multiply N with any constant, in BigO notation it's still N. And you can multiply log(N) with any constant, it's still log(N).
So BigO notation characterizes algorithms in terms of broad complexity classes. In this case it says, this algorithm responds logarithmically to input so it's O(log(N)). It doesn't bother with different shades of logaritmicality. Logarithmic is logarithmic is logarithmic.
Last edited by nuzzle; January 23rd, 2010 at 08:19 AM.

January 23rd, 2010, 12:05 AM
#5
Re: how is O(logm+logn) = O(log(m+n))? O is big oh.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!
