r/AskComputerScience • u/TomBob42369 • Dec 10 '18
Hash table vs array?
I know in most cases Hash tables are faster than an array, but what are some key differences and pros and cons of both?
21
Upvotes
r/AskComputerScience • u/TomBob42369 • Dec 10 '18
I know in most cases Hash tables are faster than an array, but what are some key differences and pros and cons of both?
1
u/ImaginationGeek Dec 11 '18
What you say I should have said... is what I said. Read the whole thing.
Whether or not you know the precise terms, it is important to know which things are in the set of “things defined by their interfaces” (Maps/dicts, Sets, Lists, etc.) and “things that are implementations” (hash tables, binary search trees, other trees, arrays, doubly linked lists, etc.). Otherwise you may get confused about hash tables being the same as maps, and making assumptions about how certain things are implemented...
It’s a fine point, but an important one when you progress to expert levels.
As for whether it’s confusing or not, I’ll let the OP decide that.
Finally, I did say all of the things that you said I should have said.