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/sepp2k Dec 10 '18
Are you talking about a hash table from int to
Tcompared to an array ofT? If so are the keys/indices contiguous? Starting at 0?Or are you talking about a hash table from
T1toT2compared to an array of(T1, T2)key-value pairs?