|
|
|
|
|
by pluma
3525 days ago
|
|
...which is irrelevant depending on the bounds of the input size. It boils down to optimization. There's no point in spending time optimizing for Big-O if the input size will be so small the difference between O(n²) and O(n log n) doesn't matter. As with all optimizations, there are situations where it matters a lot. But in the real world there are plenty of situations where the time is better spent elsewhere or where there are other things that will necessitate replacing the code before the performance becomes a problem. |
|
What about O(n!) and O(logn)?
I think that will probably explode even at microscopic input sizes.
Even in the real world, understanding what O is helps a lot. That doesn't mean you should use it everywhere or that you have to.
But it means you should understand how your code scales. Efficient code scales because it has a low order, inefficient code doesn't scale because it has a high order.
And if you replace the code, what have you done but change the order of the algorithm?
Computers are just a collection of functions with some order, some are O(n!), some O(1), some O(infinity) and some others are O(nlogn). Big-O is everywhere no matter if you admit it or not, so understanding it can be a big help to understand why Code A is faster or slower than Code B