As n gets large, of the two functions log*(log n) and log(log* n) will will be faster?
Here, the log* function is the iterated logarithm, defined here:
I suspect these are the same, just written differently, but is there any difference between them?
Clearly log(n) is smaller than n hence algorithm of complexity O(log(n)) is better. Since it will be much faster.
O(log log n) is better time complexity O(log n) because log log n is smaller than log n.
Exponential functions grow very quickly, so exponential algorithms are only useful for small problems.
No. logn≈logn2 within a constant factor, that is, the growth rate is the same! logn is related to n in exactly the same way that n is related to 2n.
log* n is the iterated logarithm, which for large n is defined as
log* n = 1 + log*(log n)
Therefore, log*(log n) = (log* n) - 1, since log* is the number of times you need to apply log to the value before it reaches some fixed constant (usually 1). Doing another log first just removes one step from the process.
Therefore, log(log* n) will be much smaller than log* (log n) = log* n - 1 since log x < x - 1 for any reasonably large x.
Another, more intuitive way to see this: the log* function is significantly better at compressing large numbers than the log function is. Therefore, if you wanted to take a large number and make it smaller, you'd get way more efficiency by computing log* n first to contract n as much as you can, then use log on that (log (log* n)) to pull down what's left.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With