Swerrgy Smith wrote:
What do you mean when you say the constant is not a concern?
For example, I think an algorithm with complexity of log(n) is better than an algorithm with complexity of 2*log(n) (2 is a constant).
Paul Clapham wrote:You can think that if you like, but it isn't right. An algorithm of complexity log(N) means that as N goes to infinity, the time taken to complete the algorithm goes to C*log(N) where C is some constant. And so "complexity 2*log(N)" means exactly the same thing as "complexity log(N)". Which is why you never see algorithm experts talking about "complexity 2*log(N)".
To add to that, a big O of "(23 * N^2) + (34 * log (N)) + 96)" is the same as a big O of "N^2". When N approaches infinity, the lower growing terms tends to disappear. This is also why you never see algorithm experts with complex compound expressions for complexity.
Henry