Gregory Smith21 said:It could be too much data for the machine—it really just comes down to how you write the code and what kind of processor you're running.
Yeah, that’s definitely true—but you can always pick a constant so small that the computer can't even handle it, meaning it just sees it as zero. Honestly, you could fill the entire universe with the fastest parallel processors and memory imaginable, and still choose a constant that's just too tiny. 😁
What I find interesting, though, is the idea of optimal algorithms. Take a meaningful problem that belongs to a non-empty class of algorithms designed to solve it—there's always going to be an algorithm in that group with the best complexity, basically the one that's asymptotically the fastest. For instance, when sorting $n$ items, we know the best complexity for that class is $O(n \log n)$; researchers actually built several algorithms with that complexity and mathematically proved nothing can be "faster."
Then you have these algorithmically solvable problems where finding an optimal algorithm is questionable—maybe even theoretically impossible—even though we know one must exist! And for some problems, we don't even know what the best possible complexity would be, which is its own kind of headache.
When we actually know what the optimal complexity is, the goal shifts to shrinking that constant inside the Big O notation—and people spend a ton of energy trying to do exactly that and publishing their results.
It’s also pretty wild that there are problems solved by
non-optimal algorithms that actually turn out to be faster on average in real-world practice than the "optimal" ones. Sorting is one of those cases.
The core question will always be:
Can we do better?EDIT: I used the word
trivial earlier, but now I'm wondering if every meaningful problem actually has an optimal algorithmic solution. 🤔 Sure, for a given input, it does, but that doesn't feel like a complete answer to me. 🤔 Man, you really dug deep into this one. ☕