2 ms·
> Most experienced programmers will realize this is a linear search and that it may be slow on large arrays. Experienced programmer can think that values in a
by citrin_ru 6y ago
> Most experienced programmers will realize this is a linear search and that it may be slow on large arrays.
Experienced programmer can think that values in a list with such operation are indexed by a hash and delete by value is O(1) unless there is a big warning in documentation. Novice programmer probably haven’t seen such combination of an array and a hash table and will assume O(N) as taught in a college.
- wizzwizz4 6y agoExperienced programmers will know that such a thing is possible, but I've never seen any (non-JavaScript, non-PHP) language where primitive arrays involve a hash table.
- Gaelan 6y agoAnd even in JS and PHP (and Lua) where arrays and hash tables are technically the same data structure, a hash table used as an array isn't actually indexed on elements, just numbers, so you don't get O(1) search.
- thezilch 6y agoExperienced programmers, if perf matters to their project, should think about their data structures, memory size, and access patterns. It's not clear why an experienced programmer would think an array defaults to wasting memory on a hash table. Why use an array, if they need lots of values and to delete them at random?
- shakow 6y agoExperienced programmer will know whether the vanilla array of the language they use feature this kind of convoluted data structure. Which, for virtually all languages, is “obviously not”.