3 ms·
I've run into plenty of cases where something was unacceptably, brokenly slow for a handful of inputs, and I wanted to figure out why, and then I realized "Oh,
by pjscott 13y ago
I've run into plenty of cases where something was unacceptably, brokenly slow for a handful of inputs, and I wanted to figure out why, and then I realized "Oh, this bit of code is O(n^2) and it's running into a weird edge case with a large n", and then fixed it. I've also run into cases of regular expressions running in exponential time, which is always entertaining.
- mmanfrin 13y agoYes, but you saw code was not optimized, you didn't see the letters "O(n^2)" in the code. I'm not asking why optimization is important, I'm asking about the notation that only seems to appear in interviews.
- fournm 13y agoThe notation just happens to give a good shorthand when discussing bits of code, as it tends to be rather fast to calculate.
- lukeschlather 13y agoBig-o is about a specific class of optimization, and a theoretical understanding of it is important. It is important to distinguish between asymptotic optimization vs. i/o optimization vs. code optimization. I'd argue if you can't do the first one you're less likely to be able to handle the next two. Yes, you can do it intuitively to some extent. However, I think it's important to be systematic about it so we can have meaningful conversations about it beyond "doing it this way is slow and if we do it this way it's faster."