← Data Structures & Algorithms learning path
Data Structures & Algorithms · Module 6 of 10

Hashing

Look up data in constant time with hash tables.

📖 Key ideas

  1. Hash tables map keys to values using a hash function.
  2. Average O(1) insert, search and delete.
  3. Collisions handled by chaining or open addressing.
  4. Python dict, Java HashMap, C++ unordered_map.
  5. Used for counting, deduplication, caching and two-sum.
💡 Real-life example: A hash table is a locker room where a formula turns your name into your locker number.
Hash tableKey-value store using hashing
Hash functionMaps keys to indices
CollisionTwo keys map to the same slot
Load factorFill ratio of the table