Hacker News new | past | comments | ask | show | jobs | submit login

O(N) random reads and O(N) random inserts can quickly turn a wide rage of things to be compute bound. Creating a linked list from scratch via random insertions for example is an N^2 operation with surprisingly large constants.

Now sure, if it’s small and you’re only creating then reading it once then that’s fine. But, you’re assumptions need to be accurate or you just created a problem.




In most of the cases where I’m using a list or array, I’m adding items to one end and then iterating forward over the structure a handful of times.

But, yeah, if you’re relying heavily on random access, pick a vector/array or some kind of tree/hash table.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: