5 ms·
Wouldn’t searching for an element in an arbitrary array of size n happen in O(n) time, while only accessing it is considered O(1)? I could understand the search
by Drod718 7y ago
Wouldn’t searching for an element in an arbitrary array of size n happen in O(n) time, while only accessing it is considered O(1)? I could understand the search case for something like a hash table being O(1) but does that also apply to your standard array?
- throwawaymath 7y agoAh, I misspoke. I meant "access", you're correct about searching. The original link I cited for explanation still applies.