Explain Amortized Complexity in Hash Tables

Updated Apr 28, 2026

Short answer

Occasional expensive rehashing is spread out over many O(1) operations, keeping the average low.

Deep explanation

Intermediate hash table mechanics focus on optimization and collision management. Occasional expensive rehashing is spread out over many O(1) operations, keeping the average low.

Real-world example

Database indexing for unique identifiers.

Common mistakes

  • Forgetting that resizing requires re-calculating the hash for every existing item.

Follow-up questions

  • Why is table size usually a prime number?

More Hash Tables interview questions

View all →