hash_table — 8 buckets, separate chaining
Empty table. Insert a key to start.
What is hashing
Hashing turns a key into a small integer so you can jump straight to a bucket instead of scanning a list. A hash table stores those buckets. Average insert, search, and delete are O(1). When two keys land in the same bucket, that is a collision — they chain together in that slot.
key % 8.dict / set, C++ unordered_map, Java HashMap.Pseudocode & complexity
| Operation | Average | Worst |
|---|---|---|
| Insert | O(1) | O(n) |
| Search | O(1) | O(n) |
| Delete | O(1) | O(n) |
Python set / dict