InterviewStack.io LogoInterviewStack.io

Hashing and Hash Tables Questions

How hash tables and hash-based structures work internally, and how to reason about their performance and correctness. Covers hash function properties (determinism, uniform distribution, speed, avalanche effect), cryptographic versus non-cryptographic hash choices, collision resolution (separate chaining, open addressing: linear probing, quadratic probing, double hashing, Robin Hood hashing, cuckoo hashing), load factor and amortized-cost resizing, and what makes an object hashable (the __hash__/__eq__ contract, immutability, custom composite keys). Covers hash-map-backed cache design (LRU and LFU eviction, TTL) and thread-safe concurrent hash maps (lock striping, CAS-based updates, safe concurrent resizing). Also covers hash-based structures beyond arrays and strings: consistent hashing for distributed routing and sharding, hash joins, hash-flooding and algorithmic-complexity security attacks and their mitigations, and probabilistic membership/cardinality structures such as Bloom filters, Cuckoo filters, Count-Min Sketch, and HyperLogLog. Excludes using a hash map purely as an optimization trick inside an array or string problem (two-sum, group anagrams, longest substring without repeating characters); that pattern belongs to Arrays, Strings, and Hashing. This topic is about the hash table itself: how it is built, how it fails under skewed or adversarial input, and how it scales.

HardSystem Design
67 practiced

Design a system to deduplicate 10 billion text documents (avg 2KB) at ingest time with expected duplicate fraction 5%. Requirements: near-real-time detection (<1s per doc), false positive rate < 1e-6, throughput 50k docs/sec, incremental updates allowed. Describe hashing strategy, sharding, storage choices, collision handling and verification, memory estimates, and fallback strategies.

HardTechnical
56 practiced

You are given a static set of millions of strings built once and then used only for lookups. You need O(1) lookups with minimal memory overhead. Describe an approach to build a minimal perfect hash function (MPHF) for the set, outline trade-offs, and provide pseudocode or a small Python builder sketch for a small example set.

MediumTechnical
60 practiced

Compare Java's HashMap and Python's dict internal resizing and rehashing strategies. Explain iteration order guarantees, how rehash affects latency spikes, and practical impacts for serving ML models using large dictionaries for feature lookups.

EasyTechnical
72 practiced

Explain the concept of load factor in hash tables and how it affects performance and memory usage. Describe the resize (rehash) operation when capacity is doubled and provide an amortized analysis showing that average insertion cost remains O(1). Discuss trade-offs of different resize thresholds (e.g., 0.5 vs 0.75).

HardTechnical
68 practiced

You need a hashing/indexing approach to partition geographic coordinates (latitude, longitude) into buckets for fast lookup and approximate nearest neighbors. Propose and compare approaches such as geohash and Morton/Z-order (Morton code). Discuss locality preservation, collision behavior, bucket size tuning, and how to support range and neighbor queries efficiently.

Unlock Full Question Bank

Get access to all Hashing and Hash Tables interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.