Loading...
Hash tables, functions, collision resolution, and applications
Section 1 of 4
Understanding the core concepts behind lightning-fast data structures
A hash table is a data structure that implements an associative array, mapping keys to values using a hash function to compute an index into an array of buckets or slots.
Simple modular arithmetic approach
h(k) = k mod mSame key always produces same hash value
Keys spread evenly across hash table
Efficient to calculate in constant time
Small key changes produce large hash changes
| Operation | Average Case | Worst Case | Best Case |
|---|---|---|---|
| Search | O(1) | O(n) | O(1) |
| Insert | O(1) | O(n) | O(1) |
| Delete | O(1) | O(n) | O(1) |