3 ms·
you actually can't though. Forget everything you have learned about the famous BigO analysis for 99% of the cases because it assumes a computing model that is
by cowl 3y ago
you actually can't though.
Forget everything you have learned about the famous BigO analysis for 99% of the cases because it assumes a computing model that is no where near what we have today. It was close in the 80-s but now it's totally wrong.
the most glaring example i can offer is that nowdays for example a datastructure based on a linked list will almost always be slower than one based on arrays even though the BigO analyses says otherwise.
CPU cache plays a much bigger role and it pays more to chase a consistent cache access rather than jumping all over through pointers and thrasshing the cache.
likewise most algorithms would be faster looping through all array items rather than for example using a set or hashMap when number of items is small (and by small we are still talking about hundreds of elements, the exact number when one datastructure becomes better than the other will depend on many factors.
that's why, don't assume but measure, it's the best advice there is.
- IshKebab 3y ago> you actually can't though. Well, yes I can because I know everything you just said already... > a datastructure based on a linked list will almost always be slower than one based on arrays even though the BigO analyses says otherwise. Cache locality is one reason that linked lists are usually slower, but I think you've got a bit mixed up because the big O analysis also says they'll be slower (in most common cases). > that's why, don't assume but measure, it's the best advice there is. You missed my point (thus proving why this is misleading advice!)