From e0565eb0ca2592bfabcda1615fe9b4b5f4ac1967 Mon Sep 17 00:00:00 2001 From: Si Lam Date: Sat, 1 Oct 2022 08:19:48 -0500 Subject: [PATCH 1/5] Description of DOuble hasing --- data_structures/hashing/double_hash.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/data_structures/hashing/double_hash.py b/data_structures/hashing/double_hash.py index bd1355fca65d..c6d17250591e 100644 --- a/data_structures/hashing/double_hash.py +++ b/data_structures/hashing/double_hash.py @@ -1,3 +1,25 @@ +""" +Double hashing is a collision resolving technique in +Open Addressed Hash tables. Double hashing uses the idea of +applying a second hash function to key when a collision occurs. + +Advantages of Double hashing + +The advantage of Double hashing is that it is one of the best form of +probing, producing a uniform distribution of records throughout a hash table. +This technique does not yield any clusters. +It is one of effective method for resolving collisions. + +Double hashing can be done using : +(hash1(key) + i * hash2(key)) % TABLE_SIZE + +Here hash1() and hash2() are hash functions and TABLE_SIZE + +is size of hash table. + +Reference: https://en.wikipedia.org/wiki/Double_hashing#:~:text=Double%20hashing%20is%20a%20computer,data%20structure%20on%20a%20table%20. + +""" #!/usr/bin/env python3 from .hash_table import HashTable from .number_theory.prime_numbers import is_prime, next_prime From 9878b8f640137b46761a18ad01123e3135c468a1 Mon Sep 17 00:00:00 2001 From: Si Lam Date: Sun, 2 Oct 2022 07:21:23 -0500 Subject: [PATCH 2/5] Fix sheebang --- data_structures/hashing/double_hash.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/data_structures/hashing/double_hash.py b/data_structures/hashing/double_hash.py index c6d17250591e..17b1f49c2786 100644 --- a/data_structures/hashing/double_hash.py +++ b/data_structures/hashing/double_hash.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 """ Double hashing is a collision resolving technique in Open Addressed Hash tables. Double hashing uses the idea of @@ -18,9 +19,7 @@ is size of hash table. Reference: https://en.wikipedia.org/wiki/Double_hashing#:~:text=Double%20hashing%20is%20a%20computer,data%20structure%20on%20a%20table%20. - """ -#!/usr/bin/env python3 from .hash_table import HashTable from .number_theory.prime_numbers import is_prime, next_prime From 32fc8004d0924820fa9fab307830f4ae7fb6f5f0 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 30 Oct 2022 08:10:11 +0100 Subject: [PATCH 3/5] Update double_hash.py --- data_structures/hashing/double_hash.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/data_structures/hashing/double_hash.py b/data_structures/hashing/double_hash.py index 17b1f49c2786..30363f54e13a 100644 --- a/data_structures/hashing/double_hash.py +++ b/data_structures/hashing/double_hash.py @@ -1,22 +1,13 @@ #!/usr/bin/env python3 """ -Double hashing is a collision resolving technique in -Open Addressed Hash tables. Double hashing uses the idea of -applying a second hash function to key when a collision occurs. - -Advantages of Double hashing - -The advantage of Double hashing is that it is one of the best form of -probing, producing a uniform distribution of records throughout a hash table. -This technique does not yield any clusters. -It is one of effective method for resolving collisions. - -Double hashing can be done using : -(hash1(key) + i * hash2(key)) % TABLE_SIZE - -Here hash1() and hash2() are hash functions and TABLE_SIZE - -is size of hash table. +Double hashing is a collision resolving technique in Open Addressed Hash tables. +Double hashing uses the idea of applying a second hash function to key when a collision +occurs. The advantage of Double hashing is that it is one of the best form of probing, +producing a uniform distribution of records throughout a hash table. This technique +does not yield any clusters. It is one of effective method for resolving collisions. + +Double hashing can be done using: (hash1(key) + i * hash2(key)) % TABLE_SIZE +Where hash1() and hash2() are hash functions and TABLE_SIZE is size of hash table. Reference: https://en.wikipedia.org/wiki/Double_hashing#:~:text=Double%20hashing%20is%20a%20computer,data%20structure%20on%20a%20table%20. """ From 0fa7155d9f4a1526e2139ae7f03f224b45be21bb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 30 Oct 2022 07:11:04 +0000 Subject: [PATCH 4/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- data_structures/hashing/double_hash.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data_structures/hashing/double_hash.py b/data_structures/hashing/double_hash.py index 30363f54e13a..37858250245b 100644 --- a/data_structures/hashing/double_hash.py +++ b/data_structures/hashing/double_hash.py @@ -6,8 +6,8 @@ producing a uniform distribution of records throughout a hash table. This technique does not yield any clusters. It is one of effective method for resolving collisions. -Double hashing can be done using: (hash1(key) + i * hash2(key)) % TABLE_SIZE -Where hash1() and hash2() are hash functions and TABLE_SIZE is size of hash table. +Double hashing can be done using: (hash1(key) + i * hash2(key)) % TABLE_SIZE +Where hash1() and hash2() are hash functions and TABLE_SIZE is size of hash table. Reference: https://en.wikipedia.org/wiki/Double_hashing#:~:text=Double%20hashing%20is%20a%20computer,data%20structure%20on%20a%20table%20. """ From 3f98a7f5a5018dca38f7c17b7e9bc6759882c7a3 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 30 Oct 2022 08:17:39 +0100 Subject: [PATCH 5/5] Update double_hash.py --- data_structures/hashing/double_hash.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/hashing/double_hash.py b/data_structures/hashing/double_hash.py index 37858250245b..453e0d13106d 100644 --- a/data_structures/hashing/double_hash.py +++ b/data_structures/hashing/double_hash.py @@ -9,7 +9,7 @@ Double hashing can be done using: (hash1(key) + i * hash2(key)) % TABLE_SIZE Where hash1() and hash2() are hash functions and TABLE_SIZE is size of hash table. -Reference: https://en.wikipedia.org/wiki/Double_hashing#:~:text=Double%20hashing%20is%20a%20computer,data%20structure%20on%20a%20table%20. +Reference: https://en.wikipedia.org/wiki/Double_hashing """ from .hash_table import HashTable from .number_theory.prime_numbers import is_prime, next_prime