Skip to content

Commit ca92338

Browse files
silamcclausspre-commit-ci[bot]
authored
Description of Double hasing (TheAlgorithms#6467)
* Description of DOuble hasing * Fix sheebang * Update double_hash.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update double_hash.py Co-authored-by: Christian Clauss <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ba576a9 commit ca92338

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

data_structures/hashing/double_hash.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
#!/usr/bin/env python3
2+
"""
3+
Double hashing is a collision resolving technique in Open Addressed Hash tables.
4+
Double hashing uses the idea of applying a second hash function to key when a collision
5+
occurs. The advantage of Double hashing is that it is one of the best form of probing,
6+
producing a uniform distribution of records throughout a hash table. This technique
7+
does not yield any clusters. It is one of effective method for resolving collisions.
8+
9+
Double hashing can be done using: (hash1(key) + i * hash2(key)) % TABLE_SIZE
10+
Where hash1() and hash2() are hash functions and TABLE_SIZE is size of hash table.
11+
12+
Reference: https://en.wikipedia.org/wiki/Double_hashing
13+
"""
214
from .hash_table import HashTable
315
from .number_theory.prime_numbers import is_prime, next_prime
416

0 commit comments

Comments
 (0)