(no title)
metric10 | 3 years ago
For example:
1. When n is small, an array is almost always better. Arrays have very little overhead compared to even a hash map.
2. Algorithms with the same O() may still have significant differences at runtime and might be balanced differently between insert and search times. AVL trees take longer than Red Black trees to insert, but might be 1 level better in height. That means one less access. Useful for a routing table, for example.
So, in summary, if your looking at other people’s code and see lots of arrays don’t get too smug…n is usually small.
adhoc32|3 years ago
unknown|3 years ago
[deleted]
sterlind|3 years ago
weirdly, in all my recent algorithm work, only the big-O has mattered (or it's all just NP-hard or even EXPTIME.)