Rust-Cache
crates.io
crates.io
Maybe one of the users forgot to cache their deps (:
Heck, let's go even further. All the computers I've used have a fixed amount of memory, addressable by a u64, so I guess all my algorithms are constant time now.
I guess we've solved the interview, folks.
If we considered the bits of integers as the smallest unit of work in all cases (it is of course relevant to consider bits as the unit of work in some cases), then big-O notation becomes a lot more tedious without typically adding more value.
See: https://cs.stackexchange.com/questions/140642/silly-question...
https://en.wikipedia.org/wiki/Big_O_notation#Orders_of_commo...
Read the links I've provided. The convention and meaning are clear here.
This feels to me like errant niggling for the sake of it.
> In each case, c is a positive constant and *n increases without bound*
It is indeed crystal clear what "asymptotic" means. If you have a definition for O-notation in non-asymptotic contexts, I have never heard of it.
Now the OP's idea is this: I'll fix the size of allowed elements in my list to some maximum value, lets say n=5, and then you always end up with the same worst-case time, O(1), because the input size is constant. With 5 elements it looks silly but you could say n = (very large number that won't be exceeded ever) and conclude that O(n=1). In OPs case the n is the number of bits in the key (implies a radix-tree)
=> If an algorithm is defined as being unscalable (fixed input), what sense does it make to describe that it scales constantly with input size?
> If an algorithm is defined as being unscalable (fixed input), what sense does it make to describe that it scales constantly with input size?
I'll answer your question with another: in what cases does it make sense to describe the scaling behavior of an algorithm as O(1)?
I'll try one last time. I personally feel like this answer[1] very clearly refutes the criticism leveled in the top-level comment[2]. Specifically, the opening parts of the answer:
> It depends on the computational model you choose. It is obviously not true that two numbers can be added together in constant time regardless of their size. If you think about it in terms of the most elementary operations, those on individual bits, adding two n-bit numbers would require O(n) elementary operations. And multiplying two n-bit numbers would use O(n2) elementary operations if you do it using long multiplication. You can easily try this out for yourself using pen and paper.
> The problem with this viewpoint is that it makes analyzing algorithms very tedious. Any time we would add two numbers a and b we would have to figure out that they would have loga and logb bits respectively and that the addition would take O(loga+logb) time. This would make the analysis much more tedious, and result in running time with lots of logs in them.
And thus, by convention, big-O notation typically uses an `n` that is defined in terms of units of bits and not just bits themselves. This is why it can make sense to declare something O(1) even when it might actually be O(logn) where n is the number of bits in the input.
I don't disagree with this at all, now the question is: what is n in the case we are talking about? That goes to infinity as we evaluate the cost of this cache system, allowing us to use *asymptotic O notation*?
This is the difference between a mid-level and a senior engineer during an interview. The latter will explain to you the pitfalls of what you are asking for before even considering writing a line of code.