Please, help me to compare complexity of two algorithms.
O(N+1000) + O(M*log(M))O(N*5) + O(2000)
N = 100000
M = 100
I can’t understand, what should I do with O(...)? Can I leave it? And just do…
(N+1000) + (M*log(M)) = 101200
(N*5) + 2000 = 502000
Is it right?
Thank you
UPDATED
I have task and I have two probable solutions for it. First solution’s algorithm complexity O(N) + O(M log(M)), see http://code.google.com/p/redis/wiki/ZunionstoreCommand ; the second solution consists of two algorithms with complexities O(N) http://code.google.com/p/redis/wiki/SunionCommand and O(N*M) http://code.google.com/p/redis/wiki/SinterCommand. I thought that I can replace N and M with real world values to compare speed of both solutions.
Big-O notation does not tell you how fast a specific algorithm is for a specific data set – it tells you about the asymptotic performance. In Big-O notation you can ignore constants and constant coefficients:
Now you can see that the second algorithm has better asymptotic performance.