šŸ•·ļø Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 154 (from laksa119)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ā„¹ļø Skipped - page is already crawled

šŸ“„
INDEXABLE
āœ…
CRAWLED
6 days ago
šŸ¤–
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.2 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://programming.guide/prime-numbers-in-hash-tables.html
Last Crawled2026-04-10 15:14:59 (6 days ago)
First Indexed2018-06-14 22:02:08 (7 years ago)
HTTP Status Code200
Meta TitleWhy large prime numbers are used in hash tables | Programming.Guide
Meta DescriptionTo achieve a good spread of the keys, hash functions must reach the full address space of the hash table. To avoid collisions, the hash value should not have unnecessary factors.
Meta Canonicalnull
Boilerpipe Text
Hash tables store objects in buckets. Which bucket an object ends up in depends on the hash value for the object. To transform a hash value to a valid bucket index you typically just compute modulo numBuckets where numBuckets represents the number of buckets in the hash table. Hash tables perform best when objects are spread evenly among the buckets. A hash function should therefore strive for this goal. Large hash values A hash function that only returns small values, say between 0 and 10, does not achieve a good spread if numBuckets becomes greater than 10. To maintain a good spread when there's a large number of buckets, hash functions typically scale up the values by multiplying with a large prime number. Why prime numbers? If we scaled up the values by a composite number (non-prime), say 1000, there would be many values for numBuckets where the scale would be "cancelled out" in the mod operation. 1000 % numBuckets = 0 for numBuckets = 2, 4, 5, 8, 10, … In other words, similar objects would get similar bucket indexes. This reduces the spread and makes for a poor hash function. By choosing a large prime number, we avoid this problem, since a prime number is not divisible by numBuckets unless numBuckets happens to be a multiple of that particular prime number. Comments
Markdown
## Hash Tables 1. [Hash Tables](https://programming.guide/hash-tables.html) 2. [Complexity](https://programming.guide/hash-tables-complexity.html) 3. [Hash Table Load Factor and Capacity](https://programming.guide/hash-table-load-factor-and-capacity.html) 4. [Hash Table vs Hash Set](https://programming.guide/hash-table-vs-hash-set.html) 5. [Open vs Closed Addressing](https://programming.guide/hash-tables-open-vs-closed-addressing.html) 6. [Open Addressing](https://programming.guide/hash-tables-open-addressing.html) 7. [Coalesced Hashing](https://programming.guide/coalesced-hashing.html) 8. [Cuckoo Hashing](https://programming.guide/cuckoo-hashing.html) 9. [Robin Hood Hashing](https://programming.guide/robin-hood-hashing.html) 10. [Hopscotch Hashing](https://programming.guide/hopscotch-hashing.html) 11. [2-Choice Hashing](https://programming.guide/2-choice-hashing.html) 12. [2-Left Hashing](https://programming.guide/2-left-hashing.html) 13. [Linked Hash Table](https://programming.guide/linked-hash-table.html) 14. Why large prime numbers are used in hash tables ## Top Algorithm Articles 1. [Dynamic programming vs memoization vs tabulation](https://programming.guide/dynamic-programming-vs-memoization-vs-tabulation.html) 2. [Big O notation explained](https://programming.guide/big-o-notation-explained.html) 3. [Sliding Window Algorithm with Example](https://programming.guide/sliding-window-example.html) 4. [What makes a good loop invariant?](https://programming.guide/what-makes-a-good-loop-invariant.html) 5. [Generating a random point within a circle (uniformly)](https://programming.guide/random-point-within-circle.html) [**See all algorithm articles**](https://programming.guide/algorithms.html) # Why large prime numbers are used in hash tables Hash tables store objects in buckets. Which bucket an object ends up in depends on the hash value for the object. To transform a hash value to a valid bucket index you typically just compute modulo `numBuckets` where `numBuckets` represents the number of buckets in the hash table. Hash tables perform best when objects are **spread evenly** among the buckets. A hash function should therefore strive for this goal. ## Large hash values A hash function that only returns small values, say between 0 and 10, does not achieve a good spread if `numBuckets` becomes greater than 10. To maintain a good spread when there's a large number of buckets, hash functions typically scale up the values by multiplying with a large prime number. ## Why prime numbers? If we scaled up the values by a composite number (non-prime), say 1000, there would be many values for `numBuckets` where the scale would be "cancelled out" in the mod operation. 1000 % `numBuckets` = 0 for `numBuckets` = 2, 4, 5, 8, 10, … In other words, similar objects would get similar bucket indexes. This reduces the spread and makes for a poor hash function. By choosing a large prime number, we avoid this problem, since a prime number is not divisible by `numBuckets` unless `numBuckets` happens to be a multiple of that particular prime number. ## Comments Be the first to comment\! Ā© 2016–2022 Programming.Guide, [Terms and Conditions](https://programming.guide/terms-and-conditions.html)
Readable Markdownnull
Shard154 (laksa)
Root Hash10469987800461033954
Unparsed URLguide,programming!/prime-numbers-in-hash-tables.html s443