Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 51s1 days 16 hours 1 minutes 51 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 51s1 days 16 hours 1 minutes 51 seconds.

Sign in to watch this lesson
Algorithms - Linear Data Structures · 3:55
We open up std::unordered_map on this Mac's libc++: integers hash to themselves, the bucket is the hash modulo a prime bucket count, colliding keys share a chain of heap nodes, and the table rehashes through a fixed list of primes. Knowing that list, an attacker sends 50,000 multiples of 51,437 and every key lands in one bucket, so inserts turn quadratic (over a second here, against a couple of milliseconds for random keys). A seeded splitmix64 hash scatters the same keys and keeps the clock flat; we finish with composite keys and when not to hash at all.