logoalt Hacker News

kstrauseryesterday at 11:28 AM1 replyview on HN

Nitpick: it’s still going to collide when taking the modulo to decide what bucket to put it in. If you know that the hashmap has 1000 buckets, and you spam it with multiples of 1000, you could make it put every key into the same bucket and have O(1) lookups turn into O(n). That doesn’t happen with real hash functions with random seeds.


Replies

xnorswapyesterday at 11:46 AM

Oh right, got you.