Fundamentals · Medium · Free
Explain hash maps intuitively: key, hash, bucket, collision — without language APIs.
FresherFundamentalsProgramming Fundamentals
Hash map mechanics
A hash map stores key → value. The key's hash code picks a bucket index; if two keys land in the same bucket, that's a collision—resolved by chaining (list in bucket) or open addressing (probe next slot).
diagram
hash(key) % buckets → bucket i → (key,value) chain- Average O(1) get/put if load factor stays reasonable and hash spreads keys.
- Bad hash / many collisions degrade toward O(n)—attackers can craft keys (hash DoS).
- Equals contract: equal keys must have equal hash codes.
Explain hash → index → collision strategy before naming
HashMap—shows you understand internals.