Hacker News new | ask | show | jobs
by briandw 4457 days ago
Under what conditions will a B-tree out perform a hash map? Seems like the hash map was far and away the better choice in his test.
1 comments

For insertions and lookup it is probably hard to find a situation (for large n hashes are asymptotically superior).

Trees provide some other nice properties such as maintaining an ordering (so it's fast to get the smallest argument or interate of the elements in numerical order) and always perform at the asymptotic time cost (a dynamic hash table occasionally takes O(n) when the table is resized so it might not be a good fit in a realtime situation)