> not at all.
> it means the query algorythm has a speed independant of the number of
[quoted text clipped - 5 lines]
> best sorting algorythm vaires in
> O(n ln(n))
> I think we all knew what you meant, but O(n ln(n)) is better written as
> O(n lg(n)). There is still a lot of debate about which notations to
> use for logarithms, but it is generally assumed that ln means
> log-base-e, log can either mean log-base-10 or log-base-e, and lg
> usually means log-base-2.
In that case surely it would be better written as O(n log(n)) as the
order of complexity doesn't depend on the base at all.
I'm certainly more familiar with reading either ln(n) or log(n).

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Brian Gideon - 26 May 2005 20:01 GMT
Yes, actually you're probably right. When used in Big-Oh notation log
is almost always assumed to be base 2, which means that it actually
operates on all 3 bases depending on how the notation is used. But,
like you said, it doesn't matter that much anyway in complexity
analysis unless you're trying to estimate the number of operations a
particular algorithm performs.
Brian
Jon wrote:
> > I think we all knew what you meant, but O(n ln(n)) is better written as
> > O(n lg(n)). There is still a lot of debate about which notations to
[quoted text clipped - 11 lines]
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
Jon Skeet [C# MVP] - 26 May 2005 22:22 GMT
> Yes, actually you're probably right. When used in Big-Oh notation log
> is almost always assumed to be base 2, which means that it actually
> operates on all 3 bases depending on how the notation is used. But,
> like you said, it doesn't matter that much anyway in complexity
> analysis unless you're trying to estimate the number of operations a
> particular algorithm performs.
In which case Big-Oh notation isn't the right tool for the job.
Whatever base it is, it'll be constant - and O(n) = O(kn) for any
constant k, so it doesn't matter at all.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Brian Gideon - 27 May 2005 16:05 GMT
Jon wrote:
> > Yes, actually you're probably right. When used in Big-Oh notation log
> > is almost always assumed to be base 2, which means that it actually
[quoted text clipped - 6 lines]
> Whatever base it is, it'll be constant - and O(n) = O(kn) for any
> constant k, so it doesn't matter at all.
Big-Oh is certainly not the tool for the job of determining the number
of operations an algorithm must perform. That's the job of the initial
equations that were used to get the Big-Oh in the first place. If the
initial equation contains a lg(n) or log(n) component then why would
you change that notation by saying the complexity is O(ln(n))?
I prefer using lg(n) in the initial equations because it is my belief
that there is less ambiguity in the base. I naturally carry over that
notation when writing the Big-Oh complexity because I see no compelling
reason to change it.
For example, consider the AVL tree. We want to know the runtime
complexity of a search and we know that it is a function of the height
h. For a AVL tree h <= 1.44*lg(n+1). The base is important here
because the tree is binary (it has at most 2 branches at each node).
You wouldn't want to use ln(n) because the tree doesn't have ~2.718
branches. So why would you suddenly change lg(n) to ln(n) when writing
the Big-Oh?
Brian
Jon Skeet [C# MVP] - 27 May 2005 17:38 GMT
> > In which case Big-Oh notation isn't the right tool for the job.
> > Whatever base it is, it'll be constant - and O(n) = O(kn) for any
[quoted text clipped - 5 lines]
> initial equation contains a lg(n) or log(n) component then why would
> you change that notation by saying the complexity is O(ln(n))?
Because (to my mind) ln and log are both more instantly recognisable as
being log than lg is. This could be due to a maths degree background
where log base 2 wasn't often useful - I don't think I've actually ever
seen lg before this thread. (ln and log both appear on most scientific
calculators, for instance; lg doesn't as far as I can remember - that
implies a certain amount of common readability.)
I'd pick log over ln - it's instantly readable and doesn't imply any
particular base.
What's your reason for preferring other people (who may have different
initial equations which genuinely involve ln(n)) to write O(lg(n)) to
O(ln(n))?

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Brian Gideon - 28 May 2005 03:29 GMT
Jon wrote:
> Because (to my mind) ln and log are both more instantly recognisable as
> being log than lg is. This could be due to a maths degree background
> where log base 2 wasn't often useful - I don't think I've actually ever
> seen lg before this thread. (ln and log both appear on most scientific
> calculators, for instance; lg doesn't as far as I can remember - that
> implies a certain amount of common readability.)
That's enough for me to concede. Afterall, if you aren't familiar with
it then maybe it's not as prevelant as I thought.
> I'd pick log over ln - it's instantly readable and doesn't imply any
> particular base.
I'd pick log as well. However, I still think that log does imply a
particular base. On calculators it's 10 and the Math.Log function is
e.
> What's your reason for preferring other people (who may have different
> initial equations which genuinely involve ln(n)) to write O(lg(n)) to
> O(ln(n))?
I guess my original thinking was that if it genuinely involves ln(n)
then write O(ln(n)). But, now you have me second guessing that as
well. Perhaps log(n) should always be used.
Lloyd Dupont - 27 May 2005 01:33 GMT
for your information
assuming log(n) is log10
and ln(n) is neper-ian(? not sure about the english name!) (AKA natural log)
the difference is simple
log(n) = ln(n) / ln(10)
ln(10) ~= 2.xxxx
Anyway we were saying the time is proportional to: ln(n)
so adding a constant (switching from ln to log) doesn't change this property
at all, does it?
furthermore ln(10) ~= 2 means we stay in the same order of magnitude.
Bottom line, from a 'mathematical' point of view (from a physisicist point
of view, dare I say, in fact :D :D) it doesn't matter at all!
But if you prefer the "log()" notation (if you are used to it), then I
accept that, so be it!
>> I think we all knew what you meant, but O(n ln(n)) is better written as
>> O(n lg(n)). There is still a lot of debate about which notations to
[quoted text clipped - 6 lines]
>
> I'm certainly more familiar with reading either ln(n) or log(n).