Hash Tables & Hash Functions
Hash table implementations, collision resolution strategies, hash functions, load factor, and performance characteristics.
Hash table implementations, collision resolution strategies, hash functions, load factor, and performance characteristics.
| Component | Purpose | Properties | Common functions | Example | Notes | Definition | Threshold | Rehashing | Time impact | Strategies | Description |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Hash Function | Maps arbitrary key to integer index in hash table array |
|
| h(k) = (a × k + b) mod m (affine hash for integers) | Cryptographic hashes (SHA, MD5) are slow; non-cryptographic preferred for hash tables | null | null | null | null | null | null |
| Load Factor (α) | null | null | null | null | Higher α → more collisions, slower lookups; lower α → wasted memory | Ratio of number of entries to number of buckets (n / m) | Typically 0.75 for separate chaining, 0.5-0.7 for open addressing | When α exceeds threshold, resize table (usually double) and rehash all entries | Amortized O(1) if resizing infrequent; worst-case O(n) during resize | null | null |
| Collision Resolution | null | null | null | null | null | null | null | null | null |
| Method to handle multiple keys mapping to same bucket index |
| Name | Implementation | Languages | Avg operations | Notes | Use cases | Features |
|---|---|---|---|---|---|---|
| HashMap / Dictionary | Array of buckets + hash function + collision resolution |
| O(1) | Most common associative array; maintains insertion order in some implementations (Python 3.7+) | null | null |
| HashSet | Hash table storing only keys (no values) |
| null | Backed by hash table; hash of key determines bucket |
| null |
| Concurrent Hash Map | Lock striping or lock-free segments for thread-safe access |
| null | Traditional HashMap requires external synchronization (synchronized/mutex); concurrent maps scale to many threads | null |
|
The static files are identical to what the API returns, but with no rate limit and no server round trip. Use the API when you want a query and a content type; use the files when you want to cache one document.
curl "https://yjtoon.com/api/dataset/hash-tables?format=toon"
const res = await fetch( "https://yjtoon.com/static-data/dataset/hash-tables.toon" ); const toon = await res.text();
Rate limit: 120 requests per minute per IP, no key and no signup. API reference →