A hashmap (also called a hash table) is a data structure that stores key → value pairs and supports fast insertion, deletion, and lookup on average.
In Python, the built-in implementation is dict.
mp = {"name": "Ali", "age": 20}
print(mp["name"]) # Ali
Key → Value mapping
Each key points to exactly one value.
Fast average operations
Insert / search / delete are typically O(1) average.
Keys are unique
If you insert the same key again, the value gets overwritten.
Hashing
A hash function converts a key into an index (bucket).
Collision handling
If two keys map to the same bucket, the hashmap handles it using techniques like chaining or open addressing.
A hash function takes a key and produces an integer index.
index = hash(key) % table_size
A hashmap uses an internal array of buckets.